[Server & Network General] プロセスを調べる
memo.
[markdown]
こちらで勉強。
> * [プロセスを調べる – いますぐ実践! Linuxシステム管理 / Vol.267](http://www.usupi.org/sysad/267.html)
## ps, kill
いままではこんな感じ
“`prettyprinted
% ps ax |grep sleep
14128 s000 R+ 0:00.00 grep sleep
14077 s002 S+ 0:00.00 sleep 1800
% kill 14150
“`
`kill -9` とか。
> * [Man page of SIGNAL](http://linuxjm.sourceforge.jp/html/LDP_man-pages/man7/signal.7.html)
> * [signalのメモ – 目の前に僕らの道がある](http://masasuzu.hatenablog.jp/entry/20120505/1336225840)
## pgrep, pkill
“`prettyprinted
% pgrep sleep
14175
% pgrep -l sleep
14175 sleep
% pkill sleep
“`
## pstree
Mac OS X 10.10 では入っていないようなので、brew instal します。
どうもオプションが異なるよう。
“`prettyprinted
% 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
“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
-U don’t show branches containing only root processes
-s string show only branches containing process with
-p pid show only branches containing process
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` で親子関係の起点を変更できる。
“`prettyprinted
% pstree -s Terminal
“`
[/markdown]