![psプロセス名は[]内に印刷されます。たとえば、[cgroup]とはどういう意味ですか? [コピー]](https://linux33.com/image/45789/ps%E3%83%97%E3%83%AD%E3%82%BB%E3%82%B9%E5%90%8D%E3%81%AF%5B%5D%E5%86%85%E3%81%AB%E5%8D%B0%E5%88%B7%E3%81%95%E3%82%8C%E3%81%BE%E3%81%99%E3%80%82%E3%81%9F%E3%81%A8%E3%81%88%E3%81%B0%E3%80%81%5Bcgroup%5D%E3%81%A8%E3%81%AF%E3%81%A9%E3%81%86%E3%81%84%E3%81%86%E6%84%8F%E5%91%B3%E3%81%A7%E3%81%99%E3%81%8B%EF%BC%9F%20%5B%E3%82%B3%E3%83%94%E3%83%BC%5D.png)
CentOS 6でps -auxなどのコマンドを実行すると、次のように[]内にそのコマンドがリストされているいくつかのプロセスが表示されます。名前の[]はどういう意味ですか?私はこれがある種の特別なプロセスであると仮定しています。プロセス名の周りに[]が表示されるのはなぜですか?
[root@centos6 src]# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 18:48 ? 00:00:01 /sbin/init
root 2 0 0 18:48 ? 00:00:00 [kthreadd]
root 3 2 0 18:48 ? 00:00:00 [migration/0]
root 4 2 0 18:48 ? 00:00:00 [ksoftirqd/0]
root 5 2 0 18:48 ? 00:00:00 [migration/0]
root 6 2 0 18:48 ? 00:00:00 [watchdog/0]
root 7 2 0 18:48 ? 00:00:02 [events/0]
答え1
コマンドラインにアクセスできない場合は、空のps
文字/proc/<pid>/cmdline
列が返され、ps
角かっこで囲まれます。
これを使用して次のコマンドを実行し、プロセスの一覧で確認して上記の内容をテストできます。
$ perl -e '$0 = ""; sleep'
次に、次のようにしますps
。
saml 26756 2098 0 21:21 pts/9 00:00:00 []
もちろん、私たちのperl
プロセスは角かっこ([]
)内に表示されます。
cmdlineが空です。本当にですか?
はい、少し奇妙に見えますが、確認するために最初のペアを確認しましたが、間違いなく空でした。
$ for i in `seq 2125`;do [ -e /proc/$i/cmdline ] || continue; \
echo -n "PID# $i: "; echo $(cat /proc/$i/cmdline);done | less
PID# 1: /sbin/init
PID# 2:
PID# 3:
PID# 4:
PID# 5:
PID# 15:
...
PID# 1187: /sbin/rsyslogd-c4
PID# 1189: /sbin/rsyslogd-c4
PID# 1190: /sbin/rsyslogd-c4
PID# 1211:
PID# 1229: irqbalance
PID# 1255: rpcbind
PID# 1269: mdadm--monitor--scan-f--pid-file=/var/run/mdadm/mdadm.pid
...
それらを削除?
-f
スイッチを使用すると、角括弧なしで-c
これらのプロセスの拡張バージョンを表示できます。
$ ps --version
procps version 3.2.8
$ ps -auxfc | less
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 2 0.0 0.0 0 0 ? S Aug21 0:00 kthreadd
root 3 0.0 0.0 0 0 ? S Aug21 0:04 \_ ksoftirqd/0
root 4 0.0 0.0 0 0 ? S Aug21 0:03 \_ migration/0
root 5 0.0 0.0 0 0 ? S Aug21 0:00 \_ watchdog/0
root 15 0.0 0.0 0 0 ? S Aug21 0:04 \_ events/0
root 19 0.0 0.0 0 0 ? S Aug21 0:00 \_ cpuset
root 20 0.0 0.0 0 0 ? S Aug21 0:00 \_ khelper
root 21 0.0 0.0 0 0 ? S Aug21 0:00 \_ netns
root 22 0.0 0.0 0 0 ? S Aug21 0:00 \_ async/mgr
root 23 0.0 0.0 0 0 ? S Aug21 0:00 \_ pm
root 24 0.0 0.0 0 0 ? S Aug21 0:00 \_ sync_supers
root 25 0.0 0.0 0 0 ? S Aug21 0:00 \_ bdi-default
root 26 0.0 0.0 0 0 ? S Aug21 0:00 \_ kintegrityd/0
root 30 0.0 0.0 0 0 ? S Aug21 0:07 \_ kblockd/0
root 34 0.0 0.0 0 0 ? S Aug21 0:00 \_ kacpid
root 35 0.0 0.0 0 0 ? S Aug21 0:00 \_ kacpi_notify
root 36 0.0 0.0 0 0 ? S Aug21 0:00 \_ kacpi_hotplug
root 37 0.0 0.0 0 0 ? S Aug21 0:00 \_ ata_aux
root 38 0.0 0.0 0 0 ? S Aug21 0:00 \_ ata_sff/0
root 42 0.0 0.0 0 0 ? S Aug21 0:00 \_ khubd
root 43 0.0 0.0 0 0 ? S Aug21 0:00 \_ kseriod
root 44 0.0 0.0 0 0 ? S Aug21 0:35 \_ kswapd0
root 45 0.0 0.0 0 0 ? SN Aug21 0:00 \_ ksmd
root 46 0.0 0.0 0 0 ? S Aug21 0:00 \_ aio/0
root 50 0.0 0.0 0 0 ? S Aug21 0:00 \_ crypto/0
root 59 0.0 0.0 0 0 ? S Aug21 0:00 \_ scsi_eh_0
root 60 0.0 0.0 0 0 ? S Aug21 0:26 \_ scsi_eh_1
root 61 0.0 0.0 0 0 ? S Aug21 0:00 \_ scsi_eh_2
root 62 0.0 0.0 0 0 ? S Aug21 0:00 \_ scsi_eh_3
root 63 0.0 0.0 0 0 ? S Aug21 0:00 \_ scsi_eh_4
root 64 0.0 0.0 0 0 ? S Aug21 0:00 \_ scsi_eh_5
root 71 0.0 0.0 0 0 ? S Aug21 0:00 \_ kpsmoused
root 72 0.0 0.0 0 0 ? S Aug21 0:00 \_ kstriped
マニュアルページからps
:
-c Show different scheduler information for the -l option.
-f does 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.