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
    

    出处:https://www.cnblogs.com/wanng/p/ps-command-truncation.html

    您的资助是我最大的动力!
    金额随意,欢迎来赏!
    款后有任何问题请给我留言。

    如果,您认为阅读这篇博客让您有些收获,不妨点击一下右下角的推荐按钮。
    如果,您希望更容易地发现我的新博客,不妨点击一下绿色通道的关注我。(●'◡'●)

    如果你觉得本篇文章对你有所帮助,请给予我更多的鼓励,求打             付款后有任何问题请给我留言!!!

    因为,我的写作热情也离不开您的肯定支持,感谢您的阅读,我是【Jack_孟】!

  • 相关阅读:
    pat 1034 Head of a Gang (30分)
    pta坑点
    Devc++ 编译 c++11
    Invitation Cards dijkstra法
    Cube Stacking
    畅通工程
    蚂蚁上树
    洛谷 P1439 【模板】最长公共子序列
    Recursive sequence
    A Simple Math Problem
  • 原文地址:https://www.cnblogs.com/mq0036/p/14784299.html
Copyright © 2011-2022 走看看