pidof
– find the process ID of a running program.
Help
pidof [-s] [-c] [-n] [-x] [-m] [-o omitpid[,omitpid..]] [-o omitpid[,omitpid..]..] program [program..]
参数
- -s:仅返回一个进程号
- -c:仅显示具有相同目录的进程
- -x:显示由脚本开启的进程
- -o:指定不显示的进程ID
示例
# ps -ef | grep tengine | grep -v grep
root 4700 1 0 May12 ? 00:00:00 nginx: master process /usr/sbin/tengine -c /etc/tengine/tengine.conf
tengine 6469 4700 0 Jul28 ? 00:00:03 nginx: worker process
# pidof tengine
6469 4700
# pidof -s tengine
6469
# pidof -c tengine
6469 4700
# pidof -x tengine
6469 4700