本文主要是介绍linux命令--pidof,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
文章目录
- linux命令--pidof
linux命令–pidof
pidof 是Linux系统中用来查找正在运行进程的进程号(pid)的工具,功能类似pgrep和ps。
pidof命令用于查找指定名称的进程的进程号id号。
语法
pidof(选项)(参数)
选项
-s:仅返回一个进程号;
-c:仅显示具有相同“root”目录的进程;
-x:显示由脚本开启的进程;
-o:指定不显示的进程ID。
参数
进程名称:指定要查找的进程名称。
实例
# pidof nginx
3189 985 984 983 982
# ps -ef|grep nginx
work 982 3189 0 02:02 ? 00:00:00 nginx: worker process
work 983 3189 0 02:02 ? 00:00:02 nginx: worker process
work 984 3189 0 02:02 ? 00:00:02 nginx: worker process
work 985 3189 0 02:02 ? 00:00:02 nginx: worker process
root 3189 1 0 2018 ? 00:00:02 nginx: master process nginx
root 19020 15396 0 16:45 pts/2 00:00:00 grep --color=auto nginx
1
# pidof -s nginx
3189
这篇关于linux命令--pidof的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!