最終更新:2021-02-17 (水) 04:05:45 (1164d)
ps
Top / ps
% ps auxwww
a:ほかのユーザーのプロセスも表示 u : ユーザー指向のフォーマット x:制御端末(tty)のないプロセス w:132行で表示 ww:すべて表示
-H : スレッドをプロセスのように表示する。 -L : 可能ならば LWP と NLWP カラムをつけてスレッドを表示する。 -T : 可能ならば SPID カラムをつけてスレッドを表示する。 -m : プロセスの後にスレッドを表示する
使い方
例
$ ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.1 3508 1396 ? Ss 2012 0:02 /sbin/init root 2 0.0 0.0 0 0 ? S 2012 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? S 2012 0:09 [ksoftirqd/0] root 6 0.0 0.0 0 0 ? S 2012 0:00 [migration/0] root 7 0.0 0.0 0 0 ? S 2012 0:46 [watchdog/0] root 8 0.0 0.0 0 0 ? S< 2012 0:00 [cpuset] root 9 0.0 0.0 0 0 ? S< 2012 0:00 [khelper] root 10 0.0 0.0 0 0 ? S 2012 0:00 [kdevtmpfs]
help
Usage: ps [options] Basic options: -A, -e all processes -a all with tty, except session leaders a all with tty, including other users -d all except session leaders -N, --deselect negate selection r only running processes T all processes on this terminal x processes without controlling ttys Selection by list: -C <command> command name -G, --Group <GID> real group id or name -g, --group <group> session or effective group name -p, p, --pid <PID> process id --ppid <PID> parent process id -q, q, --quick-pid <PID> process id (quick mode) -s, --sid <session> session id -t, t, --tty <tty> terminal -u, U, --user <UID> effective user id or name -U, --User <UID> real user id or name The selection options take as their argument either: a comma-separated list e.g. '-u root,nobody' or a blank-separated list e.g. '-p 123 4567' Output formats: -F extra full -f full-format, including command lines f, --forest ascii art process tree -H show process hierarchy -j jobs format j BSD job control format -l long format l BSD long format -M, Z add security data (for SELinux) -O <format> preloaded with default columns O <format> as -O, with BSD personality -o, o, --format <format> user-defined format s signal format u user-oriented format v virtual memory format X register format -y do not show flags, show rss vs. addr (used with -l) --context display security context (for SELinux) --headers repeat header lines, one per page --no-headers do not print header at all --cols, --columns, --width <num> set screen width --rows, --lines <num> set screen height Show threads: H as if they were processes -L possibly with LWP and NLWP columns -m, m after processes -T possibly with SPID column Miscellaneous options: -c show scheduling class with -l option c show true command name e show the environment after command k, --sort specify sort order as: [+|-]key[,[+|-]key[,...]] L show format specifiers n display numeric uid and wchan S, --cumulative include some dead child process data -y do not show flags, show rss (only with -l) -V, V, --version display version information and exit -w, w unlimited output width --help <simple|list|output|threads|misc|all> display help and exit For more details see ps(1).
例
EXAMPLES To see every process on the system using standard syntax: ps -e ps -ef ps -eF ps -ely To see every process on the system using BSD syntax: ps ax ps axu To print a process tree: ps -ejH ps axjf To get info about threads: ps -eLf ps axms To get security info: ps -eo euser,ruser,suser,fuser,f,comm,label ps axZ ps -eM To see every process running as root (real & effective ID) in user format: ps -U root -u root u To see every process with a user-defined format: ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm ps axo stat,euid,ruid,tty,tpgid,sess,pgrp,ppid,pid,pcpu,comm ps -Ao pid,tt,user,fname,tmout,f,wchan Print only the process IDs of syslogd: ps -C syslogd -o pid= Print only the name of PID 42: ps -q 42 -o comm=
表示される項目
属性 表示 説明 プロセスID PID プロセスを識別する番号 端末名 TIY プロセスが関連付けられている端末デバイス名 実行時間 TIME プロセスがCPUを使用した時間 コマンド CMD プロセスが起動されたコマンド名 ユーザID UID プロセスのユーザID 親プロセスID PPID 親プロセスのプロセスID CPU使用率 C 現時点のCPU使用率 メモリアドレス ADDR プロセスのメモリ上のアドレス サイズ SZ プロセスイメージのサイズ
STAT
- D - 割り込み不可能なスリープ状態 (通常 IO 中)
- R - 実行中または実行可能状態 (実行キューにある)
- S - 割り込み可能なスリープ状態 (イベントの完了を待っている)
- T - ジョブ制御シグナルまたはトレースされているために停止中の状態
- W - ページング状態 (2.6.xx カーネルからは無効)
- X - 死んだ状態 (見えるべきではない)
- Z - 終了したが、親プロセスによって回収されなかった、 消滅した (ゾンビ) プロセス
BSD 形式で stat キーワードが用いられたときは、 以下の添付文字が表示されることがある。
- < - 優先度の高いプロセス (他のユーザーに対して良くない)
- N - 優先度の低いプロセス (他のユーザーに対して良い)
- L - 実メモリのページをロックして利用している (リアルタイム処理やカスタム IO 向け)
- s - セッションリーダ
- l - マルチスレッド化されている (NPTL pthreads が行うように、CLONE_THREAD が使われている)
- + - フォアグラウンドのプロセスグループに含まれている
メモ
- "ps -aux" は "ps aux" とは異なることに注意すること。 POSIX と UNIX 標準では、"ps -aux" は "x" という名前のユーザーが所有する全てのプロセスを表示し、かつ -a オプションで選択される全てのプロセスを表示する。 "x" という名前のユーザーが存在しない場合、この ps は代わりに "ps aux" というコマンドとして解釈され、警告を表示する。この動作は昔のスクリプトと慣習からの移行の助けになることを意図している。これは脆くて変更される可能性があるので、これに依存すべきではない。