linux pidof用法,科技常识:Linux pidof命令使用总结
今天小編跟大家講解下有關Linux pidof命令使用總結 ,相信小伙伴們對這個話題應該也很關注吧,小編也收集到了有關Linux pidof命令使用總結 的相關資料,希望小伙伴會喜歡也能夠幫助大家。
一、什么是pidof命令?復制代碼 代碼如下:#man pidof中的解釋:pidof ― find the process ID of a running program.pidofC用于查找一個運行的程序的PID。pidof is actually the same program as killall5;[[email?protected] ~]# ls -l /sbin/pidoflrwxrwxrwx. 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 itis possible that it returns pids of running programs that happen to have the same name as the program you're after but areactually other programs.如果 是一個 fullpath 則 pidof 不會出錯,但如果不是則有可能返回和給定同名的程序。
三、pidof命令使用實例復制代碼 代碼如下:[[email?protected] ~]# pidof nginx1476 1475 1473 1472 1471 1470 1469 1467 1466[[email?protected] ~]# ps -ef | grep nginxnginx 1450 1449 0 20:16 ? 00:00:00 php-fpm: pool wwwnginx 1451 1449 0 20:16 ? 00:00:00 php-fpm: pool wwwnginx 1452 1449 0 20:16 ? 00:00:00 php-fpm: pool wwwnginx 1453 1449 0 20:16 ? 00:00:00 php-fpm: pool wwwnginx 1454 1449 0 20:16 ? 00:00:00 php-fpm: pool wwwroot 1466 1 0 20:16 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.confnginx 1467 1466 0 20:16 ? 00:00:00 nginx: worker processnginx 1469 1466 0 20:16 ? 00:00:00 nginx: worker processnginx 1470 1466 0 20:16 ? 00:00:00 nginx: worker processnginx 1471 1466 0 20:16 ? 00:00:00 nginx: worker processnginx 1472 1466 0 20:16 ? 00:00:00 nginx: worker processnginx 1473 1466 0 20:16 ? 00:00:00 nginx: worker processnginx 1475 1466 0 20:16 ? 00:00:00 nginx: worker processnginx 1476 1466 0 20:16 ? 00:00:00 nginx: worker processroot 2234 2141 0 20:24 pts/1 00:00:00 grep nginx[[email?protected] ~]# ps -ef | grep nginx | awk '{print $2}'145014511452145314541466146714691470147114721473147514762237[[email?protected] ~]# pidof -s nginx1476[[email?protected] ~]# pidof sshd2139 1163[[email?protected] ~]# ps -ef | grep sshdroot 1163 1 0 20:16 ? 00:00:00 /usr/sbin/sshdroot 2139 1163 0 20:20 ? 00:00:00 sshd: [email?protected]/1
來源:愛蒂網
總結
以上是生活随笔為你收集整理的linux pidof用法,科技常识:Linux pidof命令使用总结的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux系统脚本安装失败,ubuntu
- 下一篇: 基于fiddler的网络爬虫校园网自动登