個人用なのでたたかないでくだしあ
■コマンド
全プロセスの詳細表示
ps -alx
ps -alxf #階層表示
特定プロセスの詳細表示
ps -alx | grep <processname>
ps -alx | head -n 1 && ps -alx | grep <processname> #ヘッダ行を追加
全プロセスのCPU使用率、メモリ使用率を表示
ps -aux
ps -aux --sort -%cpu | head -n 10 #全プロセスからCPU使用率の上位10個
ps -aux --sort -%mem | head -n 10 #全プロセスからMEM使用率の上位10個
全プロセスの起動時刻、起動からの時間、CPU時間、ユーザを表示
ps ax -o lstart,etime,time,user,command
特定ユーザのプロセスを表示
ps l -u <username>
■説明
全プロセスの状態表示
全プロセスの状態表示
ps -alx
F UID PID PPID PRI NI VSZ RSS WCHAN STAT TTY TIME COMMAND
4 0 580 1 20 0 35136 2468 ep_pol Ss ? 0:00 /usr/lib/systemd/systemd-journald
5 998 802 1 20 0 117804 1644 poll_s S ? 0:00 /usr/sbin/chronyd
4 0 1398 1081 20 0 158924 5764 poll_s Ss ? 0:00 sshd: root@pts/0
F プロセスフラグ
1: execされていない
4: スーパーユーザー権限
5: 1+4
UID,PID,PPID ユーザID,プロセスID,親プロセスID
PRI,NI 優先度,ナイス値
VSZ,RSS 仮想メモリサイズ(KB),使用メモリサイズ(KB):実際のメモリ使用量
WCHAN プロセスがスリープしているカーネル関数の名前、動作中は - で表示
STAT プロセスステータス
D: 割り込み不可能なスリープ状態 (通常 IO 中)
R: 実行中または実行可能状態 (実行キューにある)
S: 割り込み可能なスリープ状態 (イベントの完了を待っている)
T: ジョブ制御シグナルまたはトレースされているために停止中の状態
W: ページング状態
X: 死んだ状態 (見えるべきではない)
Z: ゾンビプロセス
TTY 制御端末
TIME CPU時間(≠起動時刻)
COMMAND 引数付きコマンド
特定プロセスの詳細表示
特定プロセスの詳細表示
ps -alx | grep zabbix
1 997 1161 1 20 0 78808 1256 do_wai S ? 0:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
1 997 1162 1161 20 0 78808 1308 hrtime S ? 0:00 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
1 997 1163 1161 20 0 78808 1820 poll_s S ? 0:00 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
1 997 1164 1161 20 0 78808 1820 poll_s S ? 0:00 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
1 997 1165 1161 20 0 78808 1820 poll_s S ? 0:00 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
1 997 1166 1161 20 0 78808 2224 hrtime S ? 0:00 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
1 997 1359 1 20 0 186612 3096 hrtime S ? 0:00 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf
0 0 1421 1403 20 0 112728 972 - R+ pts/0 0:00 grep --color=auto zabbix
特定プロセスの詳細表示(ヘッダ行を追加)
ps -alx | head -n 1 && ps -alx | grep zabbix
F UID PID PPID PRI NI VSZ RSS WCHAN STAT TTY TIME COMMAND
1 997 1161 1 20 0 78808 1256 do_wai S ? 0:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
1 997 1162 1161 20 0 78808 1328 hrtime S ? 0:00 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
1 997 1163 1161 20 0 78808 1820 poll_s S ? 0:00 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
1 997 1164 1161 20 0 78808 1820 poll_s S ? 0:00 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
1 997 1165 1161 20 0 78808 1820 poll_s S ? 0:00 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
1 997 1166 1161 20 0 78808 2224 hrtime S ? 0:00 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
1 997 1359 1 20 0 186612 3096 hrtime S ? 0:00 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf
0 0 1451 1403 20 0 112728 968 - R+ pts/0 0:00 grep --color=auto zabbix
全プロセスのCPU使用率、メモリ使用率を表示
全プロセスのCPU使用率、メモリ使用率を表示
ps -aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 580 0.0 0.5 35136 2536 ? Ss 20:30 0:00 /usr/lib/systemd/systemd-journald
named 1108 0.0 11.8 170104 58944 ? Ssl 20:30 0:00 /usr/sbin/named -u named -c /etc/named.conf
chrony 802 0.0 0.3 117804 1644 ? S 20:30 0:00 /usr/sbin/chronyd
USER 実行ユーザ名
PID プロセスID
%CPU プロセスのcpu使用率、プロセスの生存期間中に実行に利用した時間のパーセンテージ
%MEM マシンの物理メモリに対するプロセスの常駐セットサイズのパーセンテージ。
VSZ,RSS 仮想メモリサイズ(KB),使用メモリサイズ(KB):実際のメモリ使用量
TTY 制御端末
STAT プロセスステータス
D: 割り込み不可能なスリープ状態 (通常 IO 中)
R: 実行中または実行可能状態 (実行キューにある)
S: 割り込み可能なスリープ状態 (イベントの完了を待っている)
T: ジョブ制御シグナルまたはトレースされているために停止中の状態
W: ページング状態
X: 死んだ状態 (見えるべきではない)
Z: ゾンビプロセス
START プロセスの起動時刻または起動日
TIME CPU時間(≠起動時刻)
COMMAND 引数付きコマンド
全プロセスの起動時刻、起動からの時間、CPU時間、ユーザを表示
全プロセスの起動時刻、起動からの時間、CPU時間、ユーザを表示
ps ax -o lstart,etime,time,user,command
STARTED ELAPSED TIME USER COMMAND
Sat Nov 21 20:30:18 2020 01:06:53 00:00:02 root /usr/lib/systemd/systemd --switched-root --system --deserialize 22
Sat Nov 21 20:30:31 2020 01:06:40 00:00:00 root /usr/libexec/postfix/master -w
Sat Nov 21 20:30:31 2020 01:06:40 00:00:00 postfix qmgr -l -t unix -u
Sat Nov 21 20:36:19 2020 01:00:52 00:00:00 root -bash
Sat Nov 21 21:01:01 2020 36:10 00:00:00 root /usr/sbin/anacron -s
Sat Nov 21 21:37:11 2020 00:00 00:00:00 root ps ax -o lstart,etime,time,user,command
特定ユーザのプロセスを表示
特定ユーザのプロセスを表示
ps l -u postfix
F UID PID PPID PRI NI VSZ RSS WCHAN STAT TTY TIME COMMAND
4 89 1335 1328 20 0 89804 4052 ep_pol S ? 0:00 pickup -l -t unix -u
4 89 1336 1328 20 0 89872 4080 ep_pol S ? 0:00 qmgr -l -t unix -u
特定ユーザのプロセスを表示(存在しないユーザの場合はエラー)
ps l -u testuser999
error: user name does not exist
Usage:
ps [options]
Try 'ps --help <simple|list|output|threads|misc|all>'
or 'ps --help <s|l|o|t|m|a>'
for additional help text.
For more details see ps(1).
■参考
ps
http://linuxjm.osdn.jp/html/procps/man1/ps.1.html
UNIXコマンド辞典 ps
https://codezine.jp/unixdic/w/ps
psコマンドまとめ
https://qiita.com/s_suzaku/items/9967fabc1dd8b9856f1a
Linuxコマンド「ps」とオプションの使い方(プロセス一覧を確認する)
https://26gram.com/linux-ps-command
ps - コマンド (プログラム) の説明 - Linux コマンド集 一覧表
https://kazmax.zpp.jp/cmd/p/ps.1.html