检查两个进程是否未在shell脚本中运行
问题描述:
如果两个进程未运行,如何检入“if”条件?检查两个进程是否未在shell脚本中运行
我用
if [ `pgrep <process name>`] does not work with ot without square brackets
using ps -aux |grep <process name> in if condition does not work, since every time
grep <process name>
is up and it will always pass
任何人有任何好的建议,我可以检查,如果只要求两个过程“而不是”运行
感谢
答
ps -aux |grep -v <process name>
-v是“逆匹配',IOW,当你正在寻找的物品不匹配时它会返回成功
答
if [ $(ps aux | grep -E "(processName1|processName2)" | grep -v grep | wc -l) -eq 0 ]
then
echo "not running"
fi
如何在if条件中使用它来检查进程是否“不”运行? – JumpOffBox 2013-04-04 17:01:00