今天在使用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.
- 在 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
- 在 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
- 在 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