Linuxpidof命令如何使用

本篇内容介绍了“Linux pidof命令如何使用”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

站在用户的角度思考问题,与客户深入沟通,找到七台河网站设计与七台河网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:成都网站制作、成都网站设计、外贸营销网站建设、企业官网、英文网站、手机端网站、网站推广、域名注册虚拟主机、企业邮箱。业务覆盖七台河地区。

一、什么是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命令如何使用”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注创新互联网站,小编将为大家输出更多高质量的实用文章!

当前题目:Linuxpidof命令如何使用
标题路径:https://www.cdcxhl.com/article18/ghicdp.html

成都网站建设公司_创新互联,为您提供面包屑导航响应式网站小程序开发外贸网站建设标签优化

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都做网站