查看进程
ProcessName 是否存在 存在则返回该进程的个数,不存在则返回0
ProcessName 为唯一进程名
ps -ef|grep ProcessName |grep -v "grep"|wc -l 或 pgrep -l ProcessName |wc -l
如:
pgrep -l call.ami.php |wc -l 的执行结果与上面相同
ProcessName 为唯一进程名
ps -ef|grep ProcessName |grep -v "grep"|wc -l 或 pgrep -l ProcessName |wc -l
如:
[root@text index]# ps -ef | grep call.ami.php
root 29151 28812 0 10:04 pts/3 00:00:00 /usr/bin/php ./call.ami.php
root 29155 28685 0 10:04 pts/1 00:00:00 grep call.ami.php
[root@text index]# ps -ef|grep call.ami.php |grep -v "grep"|wc -l
1
root 29151 28812 0 10:04 pts/3 00:00:00 /usr/bin/php ./call.ami.php
root 29155 28685 0 10:04 pts/1 00:00:00 grep call.ami.php
[root@text index]# ps -ef|grep call.ami.php |grep -v "grep"|wc -l
1
转载于:https://blog.51cto.com/strugglelinux/330219