Linux pidof命令使用總結(jié)
更新時間:2014年03月16日 16:39:53 作者:
今天GoFace給大家介紹linux pidof命令的用法,pidof命令大家或許很少見過,不過在適當?shù)膱龊嫌锰庍€是不小的
一、什么是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 — 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命令的參數(shù)
-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
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
相關(guān)文章
Linux環(huán)境下Apache服務(wù)器配置二級域名的方法詳解
這篇文章主要介紹了Linux環(huán)境下Apache服務(wù)器配置二級域名的方法,結(jié)合具體實例形式較為詳細的分析了Linux環(huán)境下Apache服務(wù)器配置二級域名的具體步驟與相關(guān)操作技巧,需要的朋友可以參考下2019-07-07
Linux下安裝軟件包報依賴等相關(guān)問題的解決方法
大家好,本篇文章主要講的是Linux下安裝軟件包報依賴等相關(guān)問題的解決方法,感興趣的同學趕快來看一看吧,對你有幫助的話,記得收藏一下2021-12-12
CentOS 安裝軟件出現(xiàn)錯誤:/lib/ld-linux.so.2: bad ELF interpreter 解決
這篇文章主要介紹了CentOS 安裝軟件出現(xiàn)錯誤:/lib/ld-linux.so.2: bad ELF interpreter 解決的相關(guān)資料,需要的朋友可以參考下2017-03-03
Linux日志中查找關(guān)鍵字及其前后的信息實例方法
在本篇文章里小編給大家整理的是關(guān)于Linux日志中查找關(guān)鍵字及其前后的信息實例方法,需要的朋友們可以學習下。2019-10-10
詳解Ubuntu 16.04 pycharm設(shè)置桌面快捷啟動方式
本篇文章主要介紹了Ubuntu 16.04 pycharm設(shè)置桌面快捷啟動方式,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-12-12

