ps参数比较多,根据需要 显示进程的信息。比如进程的启动时间,运行时间,状态,

参数

参数 -e 显示所有进程信息,-o 参数控制输出。Pid,User 和 Args参数显示PID,运行应用的用户和该应用。
-u 显示用户进程

ps -efww //david 常用
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 2016 ? 00:00:02 /sbin/init
root 2 0 0 2016 ? 00:00:00 [kthreadd]

ps -aux //bean    
    USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
    root         1  0.0  0.0  24588  1224 ?        Ss    2016   0:02 /sbin/init
    root         2  0.0  0.0      0     0 ?        S     2016   0:00 [kthreadd]


ps -ef

UID PID PPID C STIME TTY TIME CMD
root 1 0 0 2016 ? 00:00:02 /sbin/init
root 2 0 0 2016 ? 00:00:00 [kthreadd]
root 3 2 0 2016 ? 00:34:18 [ksoftirqd/0]

ps -eF

UID PID PPID C SZ RSS PSR STIME TTY TIME CMD
root 1 0 0 6147 1224 11 2016 ? 00:00:02 /sbin/init
root 2 0 0 0 0 10 2016 ? 00:00:00 [kthreadd]
root 3 2 0 0 0 0 2016 ? 00:34:18 [ksoftirqd/0]
root 5 2 0 0 0 0 2016 ? 00:00:00 [kworker/0:0H]

PROCESS STATE CODES

   Here are the different values that the s, stat and state output specifiers (header "STAT" or "S") will display to describe the state of a process:
   D    uninterruptible sleep (usually IO)
   R    running or runnable (on run queue)
   S    interruptible sleep (waiting for an event to complete)
   T    stopped, either by a job control signal or because it is being traced.
   W    paging (not valid since the 2.6.xx kernel)
   X    dead (should never be seen)
   Z    defunct ("zombie") process, terminated but not reaped by its parent.

   For BSD formats and when the stat keyword is used, additional characters may be displayed:
   <    high-priority (not nice to other users)
   N    low-priority (nice to other users)
   L    has pages locked into memory (for real-time and custom IO)
   s    is a session leader
   l    is multi-threaded (using CLONE_THREAD, like NPTL pthreads do)
   +    is in the foreground process group.

查看进程的线程

ps -eLf  #L要大写,其中LWP ,light weighted process,代表thread

UID          PID    PPID     LWP  C NLWP STIME TTY          TIME CMD
root           1       0       1  0    1 Oct30 ?        00:08:28 /sbin/init
root           2       0       2  0    1 Oct30 ?        00:03:56 [kthreadd]
root           3       2       3  0    1 Oct30 ?        00:20:07 [ksoftirqd/0]
root           5       2       5  0    1 Oct30 ?        00:00:00 [kworker/0:0H]
root           7       2       7  0    1 Oct30 ?        00:55:00 [rcu_sched]
root           8       2       8  0    1 Oct30 ?        00:00:00 [rcu_bh]
root           9       2       9  0    1 Oct30 ?        00:07:19 [migration/0]
root          10       2      10  0    1 Oct30 ?        00:00:04 [watchdog/0]

查看 进程的 运行时间

root@BTDISK-12:~# ps -C atop -o etime,pid,cmd
    ELAPSED     PID CMD
      00:29  654009 /usr/bin/atop -a -w /var/log/atop.log 600

汇总进程查看相关命令


shengguo
8 声望4 粉丝