Linux pidof命令使用總結(jié)
一、什么是pidof命令?
pidof–用于查找一個(gè)運(yùn)行的程序的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個(gè) pid
-x 表示同時(shí)返回運(yùn)行給定程序的 shell 的 pid
-o 表示告訴 piod 表示忽略后面給定的 pid ,可以使用多個(gè) -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.
如果 是一個(gè) fullpath 則 pidof 不會(huì)出錯(cuò),但如果不是則有可能返回和給定同名的程序。
三、pidof命令使用實(shí)例
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)文章
阿里云云服務(wù)器Linux系統(tǒng)掛載數(shù)據(jù)盤(pán)圖文教程
這篇文章主要介紹了阿里云云服務(wù)器Linux系統(tǒng)掛載數(shù)據(jù)盤(pán)圖文教程,阿里云服務(wù)器一般需要購(gòu)買(mǎi)額外的數(shù)據(jù)盤(pán),本文就講解如何掛載使用額外的數(shù)據(jù)盤(pán),需要的朋友可以參考下2014-09-09apache偽靜態(tài)與iis偽靜態(tài)規(guī)則與配置區(qū)別介紹
本文章來(lái)總結(jié)一下關(guān)于apache偽靜態(tài)與iis偽靜態(tài)區(qū)別介紹,主要講到了一些規(guī)則的問(wèn)題與配置區(qū)別,以后大家就可以直接在iis偽靜態(tài)轉(zhuǎn)換apache,反之也很簡(jiǎn)單哦,需要了解的碰可以參考下2012-12-12linux讓程序開(kāi)機(jī)自動(dòng)運(yùn)行最簡(jiǎn)單的方法
在本篇文章里小編給大家整理的是一篇關(guān)于linux讓程序開(kāi)機(jī)自動(dòng)運(yùn)行最簡(jiǎn)單的方法以及相關(guān)代碼,需要的朋友們學(xué)習(xí)下。2019-11-11linux vps服務(wù)器進(jìn)程kswapd0與events/0消耗大量CPU的問(wèn)題
使用了阿里云的vps服務(wù)器網(wǎng)站宕了兩次機(jī),發(fā)工單給阿里云,發(fā)現(xiàn)原因是服務(wù)器的CPU 100%了,這也是vps的弊端,內(nèi)容給的相對(duì)小2014-03-03在 CentOS 8/RHEL 8 上安裝和使用 Cockpit的方法
Cockpit 是一個(gè)基于 Web 的服務(wù)器管理工具,可用于 CentOS 和 RHEL 系統(tǒng)。最近發(fā)布的 CentOS 8 和 RHEL 8,其中 cockpit 是默認(rèn)的服務(wù)器管理工具。這篇文章主要介紹了在 CentOS 8/RHEL 8 上安裝和使用 Cockpit的方法,需要的朋友可以參考下2019-10-10Linux系統(tǒng)創(chuàng)建TCP連接流程介紹
大家好,本篇文章主要講的是Linux系統(tǒng)創(chuàng)建TCP連接流程,感興趣的同學(xué)趕快來(lái)看一看吧,對(duì)你有幫助的話記得收藏一下哦,方便下次瀏覽2021-12-12Linux用戶(hù)自定義at、cron計(jì)劃任務(wù)執(zhí)行的方法
今天小編就為大家分享一篇Linux用戶(hù)自定義at、cron計(jì)劃任務(wù)執(zhí)行的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-07-07詳解Linux系統(tǒng)無(wú)法上網(wǎng)解決方案
本篇文章主要介紹了詳解Linux系統(tǒng)無(wú)法上網(wǎng)解決方案,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-06-06