一、什么是pidof命令?
复制代码 代码如下:#man pidof中的解释:
pidof — find the process ID of a running program.
pidof–用于查找一个运行的程序的PID。
pidof is actually the same program as killall5;
[root@GoGo ~]# ls -l /sbin/pidof
lrwxrwxrwx. 1 root root 8 Aug 25 00:40 /sbin/pidof -> killall5 //的确如此。
二、pidof命令的参数
-s 表示只返回1个 pid
-x 表示同时返回运行给定程序的 shell 的 pid
-o 表示告诉 piod 表示忽略后面给定的 pid ,可以使用多个 -o 。
pidof is simply a (symbolic) link to the killall5 program, which should also be located in /sbin.
When pidof is invoked with a full pathname to the program it should find the pid of, it is reasonably safe. Otherwise it
is possible that it returns pids of running programs that happen to have the same name as the program you're after but are
actually other programs.
如果 是一个 fullpath 则 pidof 不会出错,但如果不是则有可能返回和给定同名的程序。
三、pidof命令使用实例
复制代码 代码如下:[root@GoGo ~]# pidof nginx
1476 1475 1473 1472 1471 1470 1469 1467 1466
[root@GoGo ~]# ps -ef | grep nginx
nginx 1450 1449 0 20:16 ? 00:00:00 php-fpm: pool www
nginx 1451 1449 0 20:16 ? 00:00:00 php-fpm: pool www
nginx 1452 1449 0 20:16 ? 00:00:00 php-fpm: pool www
nginx 1453 1449 0 20:16 ? 00:00:00 php-fpm: pool www
nginx 1454 1449 0 20:16 ? 00:00:00 php-fpm: pool www
root 1466 1 0 20:16 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx 1467 1466 0 20:16 ? 00:00:00 nginx: worker process
nginx 1469 1466 0 20:16 ? 00:00:00 nginx: worker process
nginx 1470 1466 0 20:16 ? 00:00:00 nginx: worker process
nginx 1471 1466 0 20:16 ? 00:00:00 nginx: worker process
nginx 1472 1466 0 20:16 ? 00:00:00 nginx: worker process
nginx 1473 1466 0 20:16 ? 00:00:00 nginx: worker process
nginx 1475 1466 0 20:16 ? 00:00:00 nginx: worker process
nginx 1476 1466 0 20:16 ? 00:00:00 nginx: worker process
root 2234 2141 0 20:24 pts/1 00:00:00 grep nginx
[root@GoGo ~]# ps -ef | grep nginx | awk '{print $2}'
1450
1451
1452
1453
1454
1466
1467
1469
1470
1471
1472
1473
1475
1476
2237
[root@GoGo ~]# pidof -s nginx
1476
[root@GoGo ~]# pidof sshd
2139 1163
[root@GoGo ~]# ps -ef | grep sshd
root 1163 1 0 20:16 ? 00:00:00 /usr/sbin/sshd
root 2139 1163 0 20:20 ? 00:00:00 sshd: root@pts/1
Linux,pidof命令
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
更新日志
- 《神话时代:重述版》评测:粉丝们的朝花夕拾
- 战锤40K星际战士2先锋职业介绍|先锋职业技能效果一览
- 战锤40K星际战士2重装职业介绍|重装职业技能效果一览
- 交错战线能源发电站推荐角色一览
- 阿波罗乐神之音《第4集出埃及记》[WAV+CUE]
- JohnWrightTrio-SouthSideSoul-1960-2024(24-192)
- AnthonyBruno-Cefalu(2024)[24-96]
- 《地狱潜者2》玩家人数飙升:终于不再削弱玩家了
- 黑神话引力!外媒分享孙悟空英文书籍:美生中国人等
- 《荒野大镖客》PC版曝光!《GTA6》疑似也有PC版
- 林宥嘉.2008-神秘嘉宾(引进版)【华研国际】【WAV+CUE】
- 徐小凤.1997-金曲精选(康艺经典珍藏系列)【康艺成音】【WAV+CUE】
- 群星.1994-非常精丫宝丽金】【WAV+CUE】
- 《赛马娘 热血喧闹大感谢祭!》评测:现代复古派对
- 《星球大战:亡命之徒》评测:还是看看远方的光剑吧