【Linux】psコマンド使用方法・各項の見方(リソース使用率の確認)

psコマンド使用方法・各項の見方

>>キャパシティープランニングとは

キャパシティープランニングを行う際、今後構築しようとしているシステムがどのくらいの
リソースを必要とするのか確認するためにも、現在のリソースの使用状況を
確認する必要があります。

そこで、使用するコマンドの1つである psコマンドを今回紹介いたします。

キャパシティープランニングについては以下の記事で紹介しているので確認してみてください!

>>psコマンドについて

psコマンドとは

psコマンドは現在稼働中のプロセス、および、プロセスごとのCPUやメモリ使用率を表示します。

psコマンドを使用することで、プロセス単位で各プロセスが使用しているCPU使用率や、
メモリ使用率などを調べることが出来ます。

vmstat、iostatコマンドでは、システム全体としてのリソース使用率を調べることが出来ましたが、
プロセスごとの使用率を確認することはできませんでした。

しかし、psコマンドを使用することで、各プロセスがどのくらいリソースを使用しているのか
確認することが出来ます。

psコマンドの書式

psコマンドの書式は以下です。

ps 「オプション」

psコマンドのオプション

psコマンドで使用できるオプションは以下のようなものがあります。

オプション説明
a端末上のすべてのプロセスを表示する。
e環境変数も表示する。
x制御端末のないプロセスも表示する。
u実行ユーザも表示する。
r実行中のプロセスのみ表示する。
l長いフォーマットで表示する。
U ユーザ名ユーザー名で選択する。
-C コマンド名コマンド名で選択する。
-eすべてのプロセスを表示する。
-f引数などを含めた完全なフォーマットで表示する。
-lロング形式で表示する。
-p PIDPIDで選択する。
-u UIDユーザーIDで選択する。

psコマンドの出力内容

以下は実際にpsコマンドを実行したときの出力内容です。
psコマンドで、システムで実行されているすべてのプロセスを表示しています。

[root@localhost test2]# ps aux
USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root          1  0.0  0.4 193816  4500 ?        Ss   14:44   0:04 /usr/lib/systemd/systemd --switched-roo
root          2  0.0  0.0      0     0 ?        S    14:44   0:00 [kthreadd]
root          4  0.0  0.0      0     0 ?        S<   14:44   0:00 [kworker/0:0H]
root          6  0.0  0.0      0     0 ?        S    14:44   0:01 [ksoftirqd/0]
root          7  0.0  0.0      0     0 ?        S    14:44   0:00 [migration/0]
root          8  0.0  0.0      0     0 ?        S    14:44   0:00 [rcu_bh]
root          9  0.0  0.0      0     0 ?        R    14:44   0:01 [rcu_sched]
root         10  0.0  0.0      0     0 ?        S<   14:44   0:00 [lru-add-drain]
root         11  0.0  0.0      0     0 ?        S    14:44   0:00 [watchdog/0]
root         13  0.0  0.0      0     0 ?        S    14:44   0:00 [kdevtmpfs]
root         14  0.0  0.0      0     0 ?        S<   14:44   0:00 [netns]
root         15  0.0  0.0      0     0 ?        S    14:44   0:00 [khungtaskd]
root         16  0.0  0.0      0     0 ?        S<   14:44   0:00 [writeback]
root         17  0.0  0.0      0     0 ?        S<   14:44   0:00 [kintegrityd]
root         18  0.0  0.0      0     0 ?        S<   14:44   0:00 [bioset]
root         19  0.0  0.0      0     0 ?        S<   14:44   0:00 [bioset]
root         20  0.0  0.0      0     0 ?        S<   14:44   0:00 [bioset]
root         21  0.0  0.0      0     0 ?        S<   14:44   0:00 [kblockd]
root         22  0.0  0.0      0     0 ?        S<   14:44   0:00 [md]
root         23  0.0  0.0      0     0 ?        S<   14:44   0:00 [edac-poller]
root         24  0.0  0.0      0     0 ?        S<   14:44   0:00 [watchdogd]

psコマンドで表示される各項目が表している内容は以下です。

項目名説明
USER実行ユーザー名。
PIDプロセスID。
%CPUプロセスのCPU使用率。
%MEMプロセスの物理メモリ使用率。
VSZ仮想メモリのサイズ(KB)。
RSS使用中の物理メモリのサイズ(KB)。
TTY制御端末名。
STATプロセスの状態と優先度(Nだと優先度が低く、<だと優先度が高い。)。
STARTプロセスの実行開始時刻。
TIME消費したCPU時間。
COMMAND実行コマンド。

psコマンドの使用例

システム上のすべてのプロセスを表示

ps -e

[root@localhost]# ps -e
   PID TTY          TIME CMD
     1 ?        00:00:05 systemd
     2 ?        00:00:00 kthreadd
     3 ?        00:00:00 kworker/0:0
     4 ?        00:00:00 kworker/0:0H
     5 ?        00:00:01 kworker/u256:0
     6 ?        00:00:00 ksoftirqd/0
     7 ?        00:00:00 migration/0
     8 ?        00:00:00 rcu_bh

ps -ef

[root@localhost test]# ps -ef
UID         PID   PPID  C STIME TTY          TIME CMD
root          1      0  0 09:41 ?        00:00:05 /usr/lib/systemd/systemd --switched-root --system --deserialize 22
root          2      0  0 09:41 ?        00:00:00 [kthreadd]
root          4      2  0 09:41 ?        00:00:00 [kworker/0:0H]
root          5      2  0 09:41 ?        00:00:01 [kworker/u256:0]
root          6      2  0 09:41 ?        00:00:01 [ksoftirqd/0]
root          7      2  0 09:41 ?        00:00:00 [migration/0]
root          8      2  0 09:41 ?        00:00:00 [rcu_bh]
root          9      2  0 09:41 ?        00:00:02 [rcu_sched]
root         10      2  0 09:41 ?        00:00:00 [lru-add-drain]
root         11      2  0 09:41 ?        00:00:00 [watchdog/0]
root         13      2  0 09:41 ?        00:00:00 [kdevtmpfs]
root         14      2  0 09:41 ?        00:00:00 [netns]
root         15      2  0 09:41 ?        00:00:00 [khungtaskd]
root         16      2  0 09:41 ?        00:00:00 [writeback]
root         17      2  0 09:41 ?        00:00:00 [kintegrityd]
root         18      2  0 09:41 ?        00:00:00 [bioset]
root         19      2  0 09:41 ?        00:00:00 [bioset]
root         20      2  0 09:41 ?        00:00:00 [bioset]
root         21      2  0 09:41 ?        00:00:00 [kblockd]
root         22      2  0 09:41 ?        00:00:00 [md]

ps -ely

[root@localhost test]# ps -ely
S   UID    PID   PPID  C PRI  NI   RSS    SZ WCHAN  TTY          TIME CMD
S     0      1      0  0  80   0  4452 48482 ep_pol ?        00:00:05 systemd
S     0      2      0  0  80   0     0     0 kthrea ?        00:00:00 kthreadd
S     0      4      2  0  60 -20     0     0 worker ?        00:00:00 kworker/0:0H
S     0      5      2  0  80   0     0     0 worker ?        00:00:01 kworker/u256:0
S     0      6      2  0  80   0     0     0 smpboo ?        00:00:01 ksoftirqd/0
S     0      7      2  0 -40   -     0     0 smpboo ?        00:00:00 migration/0
S     0      8      2  0  80   0     0     0 rcu_gp ?        00:00:00 rcu_bh
R     0      9      2  0  80   0     0     0 -      ?        00:00:02 rcu_sched
S     0     10      2  0  60 -20     0     0 rescue ?        00:00:00 lru-add-drain
S     0     11      2  0 -40   -     0     0 smpboo ?        00:00:00 watchdog/0
S     0     13      2  0  80   0     0     0 devtmp ?        00:00:00 kdevtmpfs
S     0     14      2  0  60 -20     0     0 rescue ?        00:00:00 netns
S     0     15      2  0  80   0     0     0 watchd ?        00:00:00 khungtaskd
S     0     16      2  0  60 -20     0     0 rescue ?        00:00:00 writeback
S     0     17      2  0  60 -20     0     0 rescue ?        00:00:00 kintegrityd
S     0     18      2  0  60 -20     0     0 rescue ?        00:00:00 bioset
S     0     19      2  0  60 -20     0     0 rescue ?        00:00:00 bioset
S     0     20      2  0  60 -20     0     0 rescue ?        00:00:00 bioset

BSD 構文を使用して、システム上のすべてのプロセスを表示

ps ax

[root@localhost test]# ps ax
   PID TTY      STAT   TIME COMMAND
     1 ?        Ss     0:05 /usr/lib/systemd/systemd --switched-root --system --deserialize 22
     2 ?        S      0:00 [kthreadd]
     4 ?        S<     0:00 [kworker/0:0H]
     5 ?        S      0:01 [kworker/u256:0]
     6 ?        S      0:01 [ksoftirqd/0]
     7 ?        S      0:00 [migration/0]
     8 ?        S      0:00 [rcu_bh]
     9 ?        R      0:02 [rcu_sched]
    10 ?        S<     0:00 [lru-add-drain]
    11 ?        S      0:00 [watchdog/0]
    13 ?        S      0:00 [kdevtmpfs]
    14 ?        S<     0:00 [netns]
    15 ?        S      0:00 [khungtaskd]
    16 ?        S<     0:00 [writeback]
    17 ?        S<     0:00 [kintegrityd]
    18 ?        S<     0:00 [bioset]
    19 ?        S<     0:00 [bioset]

ps axu

[root@localhost test]# ps axu
   PID TTY      STAT   TIME COMMAND
 [root@localhost wakisaka]# ps axu
USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root          1  0.5  0.4 193928  4588 ?        Ss   09:41   0:05 /usr/lib/systemd/systemd --switched-root --system --deserialize 22
root          2  0.0  0.0      0     0 ?        S    09:41   0:00 [kthreadd]
root          4  0.0  0.0      0     0 ?        S<   09:41   0:00 [kworker/0:0H]
root          5  0.1  0.0      0     0 ?        S    09:41   0:01 [kworker/u256:0]
root          6  0.1  0.0      0     0 ?        S    09:41   0:01 [ksoftirqd/0]
root          7  0.0  0.0      0     0 ?        S    09:41   0:00 [migration/0]
root          8  0.0  0.0      0     0 ?        S    09:41   0:00 [rcu_bh]
root          9  0.2  0.0      0     0 ?        R    09:41   0:02 [rcu_sched]
root         10  0.0  0.0      0     0 ?        S<   09:41   0:00 [lru-add-drain]
root         11  0.0  0.0      0     0 ?        S    09:41   0:00 [watchdog/0]
root         13  0.0  0.0      0     0 ?        S    09:41   0:00 [kdevtmpfs]
root         14  0.0  0.0      0     0 ?        S<   09:41   0:00 [netns]
root         15  0.0  0.0      0     0 ?        S    09:41   0:00 [khungtaskd]
root         16  0.0  0.0      0     0 ?        S<   09:41   0:00 [writeback]

プロセスツリーを表示するには

ps -ejH

[root@localhost]# ps -ejH
   693    680    680 ?        00:00:00   ksmtuned
  3617    680    680 ?        00:00:00     sleep
   698    698    698 ?        00:00:01   firewalld
   831    831    831 ?        00:00:00   NetworkManager
   962    962    831 ?        00:00:00     dhclient
  1156   1156   1156 ?        00:00:00   cupsd
  1157   1157   1157 ?        00:00:00   sshd
  1161   1161   1161 ?        00:00:00   tuned
  1163   1163   1163 ?        00:00:00   rsyslogd
  1167   1167   1167 ?        00:00:01   libvirtd
  1176   1176   1176 ?        00:00:01   crond
  1178   1178   1178 ?        00:00:00   atd
  1179   1179   1179 ?        00:00:00   gdm
  1258   1258   1258 tty1     00:00:16     X
  1946   1179   1179 ?        00:00:00     gdm-session-wor
  1963   1963   1963 ?        00:00:00       gnome-session-b
  2091   2091   2091 ?        00:00:00         ssh-agent
  2146   1963   1963 ?        00:00:41         gnome-shell
  2174   2174   1963 ?        00:00:00           ibus-daemon
  2178   2174   1963 ?        00:00:00             ibus-dconf
  2586   2174   1963 ?        00:00:00             ibus-engine-sim
  2307   1963   1963 ?        00:00:00         gsd-power
  2309   1963   1963 ?        00:00:00         gsd-print-notif
  2312   1963   1963 ?        00:00:00         gsd-rfkill
  2317   1963   1963 ?        00:00:00         gsd-screensaver
  2322   1963   1963 ?        00:00:00         gsd-sharing
  2323   1963   1963 ?        00:00:00         gsd-sound
  2325   1963   1963 ?        00:00:00         gsd-xsettings
  2329   1963   1963 ?        00:00:00         gsd-wacom

ps axjf

[root@localhost]# ps axjf
     1    665    665    665 ?            -1 Ss       0   0:00 /usr/libexec/bluetooth/bluetoothd
     1    693    680    680 ?            -1 S        0   0:00 /bin/bash /usr/sbin/ksmtuned
   693   3665    680    680 ?            -1 S        0   0:00  \_ sleep 60
     1    698    698    698 ?            -1 Ssl      0   0:01 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid
     1    831    831    831 ?            -1 Ssl      0   0:00 /usr/sbin/NetworkManager --no-daemon
   831    962    962    831 ?            -1 S        0   0:00  \_ /sbin/dhclient -d -q -sf /usr/libexec/nm-dhcp-helper -pf /var/run/dhclient-ens33.pid -lf /var/lib/NetworkManager/dhclient-9df6e3f9-80c1-448c-9ea2
     1   1156   1156   1156 ?            -1 Ss       0   0:00 /usr/sbin/cupsd -f
     1   1157   1157   1157 ?            -1 Ss       0   0:00 /usr/sbin/sshd -D
     1   1161   1161   1161 ?            -1 Ssl      0   0:00 /usr/bin/python2 -Es /usr/sbin/tuned -l -P
     1   1163   1163   1163 ?            -1 Ssl      0   0:00 /usr/sbin/rsyslogd -n
     1   1167   1167   1167 ?            -1 Ssl      0   0:01 /usr/sbin/libvirtd
     1   1176   1176   1176 ?            -1 Ss       0   0:01 /usr/sbin/crond -n
     1   1178   1178   1178 ?            -1 Ss       0   0:00 /usr/sbin/atd -f
     1   1179   1179   1179 ?            -1 Ssl      0   0:00 /usr/sbin/gdm
  1179   1258   1258   1258 tty1       1258 Ssl+     0   0:19  \_ /usr/bin/X :0 -background none -noreset -audit 4 -verbose -auth /run/gdm/auth-for-gdm-aCaoIL/database -seat seat0 -nolisten tcp vt1
  1179   1946   1179   1179 ?            -1 Sl       0   0:00  \_ gdm-session-worker [pam/gdm-password]
  1946   1963   1963   1963 ?            -1 Ssl   1000   0:00      \_ /usr/libexec/gnome-session-binary --session gnome-classic
  1963   2091   2091   2091 ?            -1 Ss    1000   0:00          \_ /usr/bin/ssh-agent /bin/sh -c exec -l /bin/bash -c "env GNOME_SHELL_SESSION_MODE=classic gnome-session --session gnome-classic"
  1963   2146   1963   1963 ?            -1 Sl    1000   0:49          \_ /usr/bin/gnome-shell
  2146   2174   2174   1963 ?            -1 Sl    1000   0:00          |   \_ ibus-daemon --xim --panel disable
  2174   2178   2174   1963 ?            -1 Sl    1000   0:00          |       \_ /usr/libexec/ibus-dconf
  2174   2586   2174   1963 ?            -1 Sl    1000   0:00          |       \_ /usr/libexec/ibus-engine-simple
  1963   2307   1963   1963 ?            -1 Sl    1000   0:00          \_ /usr/libexec/gsd-power
  1963   2309   1963   1963 ?            -1 Sl    1000   0:00          \_ /usr/libexec/gsd-print-notifications
  1963   2312   1963   1963 ?            -1 Sl    1000   0:00          \_ /usr/libexec/gsd-rfkill
  1963   2317   1963   1963 ?            -1 Sl    1000   0:00          \_ /usr/libexec/gsd-screensaver-proxy

セキュリティ情報を取得

ps -eo euser,ruser,suser,fuser,f,comm,label

[root@localhost wakisaka]# ps -eo euser,ruser,suser,fuser,f,comm,label
EUSER    RUSER    SUSER    FUSER    F COMMAND         LABEL
root     root     root     root     4 systemd         system_u:system_r:init_t:s0
root     root     root     root     1 kthreadd        system_u:system_r:kernel_t:s0
root     root     root     root     1 kworker/0:0H    system_u:system_r:kernel_t:s0
root     root     root     root     1 kworker/u256:0  system_u:system_r:kernel_t:s0
root     root     root     root     1 ksoftirqd/0     system_u:system_r:kernel_t:s0
root     root     root     root     1 migration/0     system_u:system_r:kernel_t:s0
root     root     root     root     1 rcu_bh          system_u:system_r:kernel_t:s0
root     root     root     root     1 rcu_sched       system_u:system_r:kernel_t:s0
root     root     root     root     1 lru-add-drain   system_u:system_r:kernel_t:s0
root     root     root     root     5 watchdog/0      system_u:system_r:kernel_t:s0
root     root     root     root     5 kdevtmpfs       system_u:system_r:kernel_t:s0
root     root     root     root     1 netns           system_u:system_r:kernel_t:s0
root     root     root     root     1 khungtaskd      system_u:system_r:kernel_t:s0
root     root     root     root     1 writeback       system_u:system_r:kernel_t:s0
root     root     root     root     1 kintegrityd     system_u:system_r:kernel_t:s0
root     root     root     root     1 bioset          system_u:system_r:kernel_t:s0
root     root     root     root     1 bioset          system_u:system_r:kernel_t:s0
root     root     root     root     1 bioset          system_u:system_r:kernel_t:s0
root     root     root     root     1 kblockd         system_u:system_r:kernel_t:s0
root     root     root     root     1 md              system_u:system_r:kernel_t:s0

ps axZ

[root@localhost]# ps axZ
LABEL                              PID TTY      STAT   TIME COMMAND
system_u:system_r:init_t:s0          1 ?        Ss     0:05 /usr/lib/systemd/systemd --switched-root --system --deserialize 22
system_u:system_r:kernel_t:s0        2 ?        S      0:00 [kthreadd]
system_u:system_r:kernel_t:s0        4 ?        S<     0:00 [kworker/0:0H]
system_u:system_r:kernel_t:s0        5 ?        S      0:01 [kworker/u256:0]
system_u:system_r:kernel_t:s0        6 ?        S      0:01 [ksoftirqd/0]
system_u:system_r:kernel_t:s0        7 ?        S      0:00 [migration/0]
system_u:system_r:kernel_t:s0        8 ?        S      0:00 [rcu_bh]
system_u:system_r:kernel_t:s0        9 ?        R      0:02 [rcu_sched]
system_u:system_r:kernel_t:s0       10 ?        S<     0:00 [lru-add-drain]
system_u:system_r:kernel_t:s0       11 ?        S      0:00 [watchdog/0]
system_u:system_r:kernel_t:s0       13 ?        S      0:00 [kdevtmpfs]
system_u:system_r:kernel_t:s0       14 ?        S<     0:00 [netns]
system_u:system_r:kernel_t:s0       15 ?        S      0:00 [khungtaskd]

ps -eM

[root@localhost]# ps -eM
LABEL                              PID TTY          TIME CMD
system_u:system_r:init_t:s0          1 ?        00:00:05 systemd
system_u:system_r:kernel_t:s0        2 ?        00:00:00 kthreadd
system_u:system_r:kernel_t:s0        4 ?        00:00:00 kworker/0:0H
system_u:system_r:kernel_t:s0        6 ?        00:00:01 ksoftirqd/0
system_u:system_r:kernel_t:s0        7 ?        00:00:00 migration/0
system_u:system_r:kernel_t:s0        8 ?        00:00:00 rcu_bh
system_u:system_r:kernel_t:s0        9 ?        00:00:02 rcu_sched
system_u:system_r:kernel_t:s0       10 ?        00:00:00 lru-add-drain
system_u:system_r:kernel_t:s0       11 ?        00:00:00 watchdog/0
system_u:system_r:kernel_t:s0       13 ?        00:00:00 kdevtmpfs
system_u:system_r:kernel_t:s0       14 ?        00:00:00 netns

rootとして動作しているすべてのプロセス(実IDと実効ID)をユーザー形式で表示

ps -U root -u root u

[root@localhost]# ps -U root -u root u
USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root          1  0.3  0.4 193928  4588 ?        Ss   09:41   0:05 /usr/lib/systemd/systemd --switched-root --system --deserialize 22
root          2  0.0  0.0      0     0 ?        S    09:41   0:00 [kthreadd]
root          4  0.0  0.0      0     0 ?        S<   09:41   0:00 [kworker/0:0H]
root          6  0.0  0.0      0     0 ?        S    09:41   0:01 [ksoftirqd/0]
root          7  0.0  0.0      0     0 ?        S    09:41   0:00 [migration/0]
root          8  0.0  0.0      0     0 ?        S    09:41   0:00 [rcu_bh]
root          9  0.1  0.0      0     0 ?        R    09:41   0:02 [rcu_sched]
root         10  0.0  0.0      0     0 ?        S<   09:41   0:00 [lru-add-drain]
root         11  0.0  0.0      0     0 ?        S    09:41   0:00 [watchdog/0]
root         13  0.0  0.0      0     0 ?        S    09:41   0:00 [kdevtmpfs]
root         14  0.0  0.0      0     0 ?        S<   09:41   0:00 [netns]

ユーザ定義のフォーマットですべてのプロセスを表示

ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm

[root@localhost]# ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm
   PID    TID CLS RTPRIO  NI PRI PSR %CPU STAT WCHAN          COMMAND
     1      1 TS       -   0  19   0  0.3 Ss   ep_poll        systemd
     2      2 TS       -   0  19   0  0.0 S    kthreadd       kthreadd
     4      4 TS       - -20  39   0  0.0 S<   worker_thread  kworker/0:0H
     6      6 TS       -   0  19   0  0.0 S    smpboot_thread ksoftirqd/0
     7      7 FF      99   - 139   0  0.0 S    smpboot_thread migration/0
     8      8 TS       -   0  19   0  0.0 S    rcu_gp_kthread rcu_bh
     9      9 TS       -   0  19   0  0.1 R    -              rcu_sched
    10     10 TS       - -20  39   0  0.0 S<   rescuer_thread lru-add-drain
    11     11 FF      99   - 139   0  0.0 S    smpboot_thread watchdog/0
    13     13 TS       -   0  19   0  0.0 S    devtmpfsd      kdevtmpfs
    14     14 TS       - -20  39   0  0.0 S<   rescuer_thread netns
    15     15 TS       -   0  19   0  0.0 S    watchdog       khungtaskd
    16     16 TS       - -20  39   0  0.0 S<   rescuer_thread writeback
    17     17 TS       - -20  39   0  0.0 S<   rescuer_thread kintegrityd
    18     18 TS       - -20  39   0  0.0 S<   rescuer_thread bioset
    19     19 TS       - -20  39   0  0.0 S<   rescuer_thread bioset
    20     20 TS       - -20  39   0  0.0 S<   rescuer_thread bioset
    21     21 TS       - -20  39   0  0.0 S<   rescuer_thread kblockd

ps axo stat,euid,ruid,tty,tpgid,sess,pgrp,ppid,pid,pcpu,comm

[root@localhost]# ps axo stat,euid,ruid,tty,tpgid,sess,pgrp,ppid,pid,pcpu,comm
STAT  EUID  RUID TT        TPGID   SESS   PGRP   PPID    PID %CPU COMMAND
Ss       0     0 ?            -1      1      1      0      1  0.3 systemd
S        0     0 ?            -1      0      0      0      2  0.0 kthreadd
S<       0     0 ?            -1      0      0      2      4  0.0 kworker/0:0H
S        0     0 ?            -1      0      0      2      6  0.0 ksoftirqd/0
S        0     0 ?            -1      0      0      2      7  0.0 migration/0
S        0     0 ?            -1      0      0      2      8  0.0 rcu_bh
R        0     0 ?            -1      0      0      2      9  0.1 rcu_sched
S<       0     0 ?            -1      0      0      2     10  0.0 lru-add-drain
S        0     0 ?            -1      0      0      2     11  0.0 watchdog/0

ps -Ao pid,tt,user,fname,tmout,f,wchan

[root@localhost]# ps -Ao pid,tt,user,fname,tmout,f,wchan
   PID TT       USER     COMMAND  TMOUT F WCHAN
     1 ?        root     systemd      - 4 ep_poll
     2 ?        root     kthreadd     - 1 kthreadd
     4 ?        root     kworker/     - 1 worker_thread
     6 ?        root     ksoftirq     - 1 smpboot_thread_fn
     7 ?        root     migratio     - 1 smpboot_thread_fn
     8 ?        root     rcu_bh       - 1 rcu_gp_kthread
     9 ?        root     rcu_sche     - 1 -
    10 ?        root     lru-add-     - 1 rescuer_thread
    11 ?        root     watchdog     - 5 smpboot_thread_fn
    13 ?        root     kdevtmpf     - 5 devtmpfsd
    14 ?        root     netns        - 1 rescuer_thread
    15 ?        root     khungtas     - 1 watchdog
    16 ?        root     writebac     - 1 rescuer_thread

sshdのプロセス ID だけを表示

ps -C ssd -o pid=

[root@localhost]# ps -C sshd -o pid=
  1157
[root@localhost]# 

PID 42のプロセスのみを表示

ps -q 2 -o comm=

[root@localhost]# ps -q 2 -o comm=
kthreadd
[root@localhost]# 

最後にゴリタンが日々愛用しているLinuxの教科書をご紹介します!

良かったら参考にしてみてください!

ゴリタンが愛用しているLinuxの教科書

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA