[Server & Network General] プロセスを調べる
memo.
こちらで勉強。
ps, kill
いままではこんな感じ
% ps ax |grep sleep
14128 s000 R+ 0:00.00 grep sleep
14077 s002 S+ 0:00.00 sleep 1800
% kill 14150
kill -9
とか。
pgrep, pkill
% pgrep sleep
14175
% pgrep -l sleep
14175 sleep
% pkill sleep
pstree
Mac OS X 10.10 では入っていないようなので、brew instal します。
どうもオプションが異なるよう。
% brew install pstree
% pstree -h
pstree $Revision: 2.36 $ by Fred Hucht (C) 1993-2013
EMail: fred AT thp.uni-due.de
Usage: pstree [-f file] [-g n] [-u user] [-U] [-s string] [-p pid] [-w] [pid ...]
-f file read input from <file> (- is stdin) instead of running
"ps -axwwo user,pid,ppid,pgid,command"
-g n use graphics chars for tree. n=1: IBM-850, n=2: VT100, n=3: UTF-8
-l n print tree to n level deep
-u user show only branches containing processes of <user>
-U don't show branches containing only root processes
-s string show only branches containing process with <string> in commandline
-p pid show only branches containing process <pid>
-w wide output, not truncated to window width
pid ... process ids to start from, default is 1 (init)
use 0 to also show kernel processes
Process group leaders are marked with '='.
-s string
, -p pid
で親子関係の起点を変更できる。
% pstree -s Terminal