Linux:Shell 检测一个进程是否正在运行
2019-06-11 本文已影响0人
白祤星
代码示例:
#!/bin/bash
while true
do
count=`ps -ef | grep 进程名 | grep -v "grep" | wc -l`
if [[ $count == 0 ]];then
echo "已经停止运行"
else
sleep 5
fi
done
持久化检测(后台运行)
setsid ./shell名.sh