• 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
    
  • 相关阅读:
    服务限流原理及算法
    Kafka 与 RabbitMQ 如何选择使用哪个?
    分布式事务之最终一致性实现方案
    如何在Ubuntu 14.04中使用systemctl?
    postgresql13 for window 安装及备份还原数据
    手把手教大家在mac上用VMWare虚拟机装Ubuntu
    在Mac平台上使用Multipass安装Ubuntu虚拟机
    如何在markdown中插入js和css
    HTML5标签
    linux
  • 原文地址:https://www.cnblogs.com/wanng/p/ps-command-truncation.html
Copyright © 2020-2023  润新知