码迷,mamicode.com
首页 > 其他好文 > 详细

pidof---找寻PID

时间:2019-11-11 21:15:20      阅读:88      评论:0      收藏:0      [点我收藏+]

标签:chmod   gre   grep   pre   指定   code   守护进程   后台   col   

pidof---找寻pid

1.根据守护进程找到pid

[root@localhost ~]# pidof sshd
2542 1622
[root@localhost ~]# ps -ef | grep sshd
root       1622      1  0 15:47 ?        00:00:00 /usr/sbin/sshd -D
root       2542   1622  0 15:52 ?        00:00:00 sshd: root@pts/0
root       2569   2546  0 15:53 pts/0    00:00:00 grep --color=auto sshd

2.找出后台shell脚本的pid

[root@localhost ~]# vim sleep.sh
#!/bin/bash
sleep 1000m

"sleep.sh" [New] 3L, 25C written                                                                                                                         
[root@localhost ~]# chmod a+x sleep.sh 
[root@localhost ~]# ./sleep.sh &
[1] 2572
[root@localhost ~]# pidof sleep.sh 
[root@localhost ~]# pidof -x  sleep.sh         # 要加-x 参数
2572
[root@localhost ~]# ps -ef | grep sleep.sh 
root       2572   2546  0 15:55 pts/0    00:00:00 /bin/bash ./sleep.sh
root       2577   2546  0 15:55 pts/0    00:00:00 grep --color=auto sleep.sh

3.-o 忽略我们指定的PID

[root@localhost ~]# pidof sshd
2542 1622
[root@localhost ~]# pidof sshd -o 1622
2542

pidof---找寻PID

标签:chmod   gre   grep   pre   指定   code   守护进程   后台   col   

原文地址:https://www.cnblogs.com/zhoujun007/p/11838465.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!