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
    
  • 相关阅读:
    1058 A+B in Hogwarts (20)
    1046 Shortest Distance (20)
    1061 Dating (20)
    1041 Be Unique (20)
    1015 Reversible Primes (20)(20 分)
    pat 1027 Colors in Mars (20)
    PAT 1008 Elevator (20)
    操作系统 死锁
    Ajax的get方式传值 避免& 与= 号
    让IE浏览器支持CSS3表现
  • 原文地址:https://www.cnblogs.com/wanng/p/ps-command-truncation.html
Copyright © 2011-2022 走看看