zoukankan      html  css  js  c++  java
  • ps 命令显示不完整的问题

    今天在使用ps命令的时候,无法查找到指定名字的进程ID,仔细查找才发现ps命令查找的结果中进程启动的命令以及参数信息被截断了

    问题实例

    用户wanng启动了一个进程 wanng_qytrunkcross, 启动参数是 config.lua 文件,执行 ps -u wanng 查询用户的进程,结果如下:

    [wanng@localhost shell]# ps -u wanng
       PID TTY          TIME CMD
    127271 ?        00:00:01 sshd
    127272 pts/4    00:00:00 bash
    127332 pts/4    00:17:19 wanng_qytrunkcros
    

    从结果中发现进程名和启动参数的显示被截断了

    解决方案

    以下是通过man ps查询到的解决办法,以下三种方法都可以解决这个问题

    w Wide output. Use this option twice for unlimited width

    -w Wide output. Use this option twice for unlimited width.

    -f Do full-format listing. This option can be combined with many other UNIX-style options to add additional columns. It also causes the command arguments to be printed. When used with -L, the NLWP (number of threads) and LWP (thread ID) columns will be added. See the c option, the format keyword args, and the format keyword comm.

    -F Extra full format. See the -f option, which -F implies.

    1. 在 ps 后面加上 -w w 选项,命令执行结果如下
    [wanng@localhost shell]# ps -u wanng -w w
       PID TTY      STAT   TIME COMMAND
    127271 ?        S      0:01 sshd: wanng@pts/4
    127272 pts/4    Ss+    0:00 -bash
    127332 pts/4    Sl    17:20 ./wanng_qytrunkcross config.lua
    
    1. 在 ps 后面加上 ww 选项,命令执行结果如下
    [wanng@localhost shell]# ps -u wanng ww
       PID TTY      STAT   TIME COMMAND
    127271 ?        S      0:01 sshd: wanng@pts/4
    127272 pts/4    Ss+    0:00 -bash
    127332 pts/4    Sl    17:20 ./wanng_qytrunkcross config.lua
    
    1. 在 ps 后面加上 -f 或 -F 选项,表示以全格式显示,命令执行结果如下
    [wanng@localhost shell]# ps -f -u wanng
    UID         PID   PPID  C STIME TTY          TIME CMD
    wanng      127271 127269  0 13:55 ?        00:00:01 sshd: wanng@pts/4
    wanng      127272 127271  0 13:55 pts/4    00:00:00 -bash
    wanng      127332      1  3 13:55 pts/4    00:18:30 ./wanng_qytrunkcross config.lua
    
  • 相关阅读:
    printf函数实现的深入剖析
    rhel/centos播放mp3文件
    GRUB(GRand Unified Boot loader)引导加载程序
    NAT DHCP WWW rc.local
    论文 毕业设计 相关 用语 评语
    Linux禁止单用户模式(single)来增强系统安全
    Kernel command using Linux system calls
    GNU-ld链接脚本浅析
    AT&T汇编心得之间接寻址和LEA指令
    Linux 汇编语言开发指南
  • 原文地址:https://www.cnblogs.com/wanng/p/ps-command-truncation.html
Copyright © 2011-2022 走看看