dongnan
总版主
总版主
  • 粉丝52
  • 发帖数2165
  • 铜币13236枚
  • 威望5838点
  • 银元150个
  • 社区居民
  • 最爱沙发
  • 忠实会员
  • 原创写手
阅读:1920回复:1

ps 命令

楼主#
更多 发布于:2014-02-26 13:41
ps 命令

示例:查找僵死的进程
ps -ef | grep defunct
zongming  2267  2238  0 09:41 ?        00:00:00 [lightdm-session] <defunct>



man
NAME
       ps - report a snapshot of the current processes.

-e              Select all processes. Identical to -A
-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.


#
dongnan
总版主
总版主
  • 粉丝52
  • 发帖数2165
  • 铜币13236枚
  • 威望5838点
  • 银元150个
  • 社区居民
  • 最爱沙发
  • 忠实会员
  • 原创写手
沙发#
发布于:2017-09-21 10:58
ps stat 列状态
示例, stat 列状态 (省略重复的列,非完整输出)
ps ax -o pid,ppid,stat,command
 PID  PPID STAT COMMAND
    1     0 Ss   /sbin/init
    2     0 S    [kthreadd]
    5     2 S<   [kworker/0:0H]
   31     2 SN   [ksmd]
  401     1 Ss   /lib/systemd/systemd-udevd --daemon
  652     1 Ssl  rsyslogd
 1113     1 Ss+  /sbin/getty -8 38400 tty4
 1210     1 SLsl lightdm
 1244  1210 Ssl+ /usr/lib/xorg/Xorg -core :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
 1382     1 Sl   /usr/lib/upower/upowerd
 1436     1 SNl  /usr/lib/rtkit/rtkit-daemon
 2452  2123 S<l  /usr/bin/pulseaudio --start --log-target=syslog
 2959  2940 S+   ssh dongnan@zongming.net
 4291  2983 T    python3
 4844  2983 R+   ps ax -o pid,ppid,stat,command

状态
ps  输出结果中的STAT列的可能标志
S    睡眠,通常是在等待某个事件的发生,如一个信号或有输入可用
R       运行,严格来说,应是“可运行”,即在运行队列中,处于正在执行或即将运行状态
D       不可中断的睡眠(等待),通常是在等待输入或输出完成
T       (terminate)停止,通常是被shell作业控制所停止,或者进程正处于调试器的控制之下
Z       (zombie)僵尸进程,通常是该进程已经死亡,但父进程没有调用wait类函数来释放该进程的资源
N (nice)低优先级任务
s       进程是会话期首进程
+       进程属于前台进程组
l      进程是多线程的
<       高优先级任务

参数
-a
    Select all processes except both session leaders (see getsid(2)) and processes not associated with a terminal.

-u userlist
    Select by effective user ID (EUID) or name.  This selects the processes whose effective user name or ID is in userlist.
    The effective user ID describes the user whose file access permissions are used by the process (see geteuid(2)).  
    Identical to U and --user.

x      
    Lift the BSD-style "must have a tty" restriction, which is imposed upon the set of all processes when some BSD-style (without "-")
    options are used or when the ps personality setting is BSD-like.  The set of processes selected in this manner is in addition to the
    set of processes selected by other means.  An alternate description is that this option causes ps to list all processes owned by you
    (same EUID as ps), or to list all processes when used together with the a option.

-o format
    User-defined format.  format is a single argument in the form of a blank-separated or comma-separated list, which offers a way to
      specify individual output columns.  The recognized keywords are described in the STANDARD FORMAT SPECIFIERS section below.  Headers
    may be renamed (ps -o pid,ruser=RealUser -o comm=Command) as desired.
    ......
游客

返回顶部