脚本检查过程和放大器;重新启动程序如果没有找到 [英] Script to check for process & restart program if not found
问题描述
我使用这个检查脚本,看是否有所谓的CCcam包运行和放大器;重新启动它,如果它不是..
#!/ bin / sh的
流程=`PS auxwww | grep的的CCcam | grep的-v grep的| AWK'{打印$ 1}'`
如果[-z$进程];然后
回声找不到的CCcam运行重新启动服务器的二进制文件。>> /var/cccamlog/cccam.check
回声&功放;&安培;日期和GT;> /var/cccamlog/cccam.check
在/ usr / local / bin目录/个CCcam -d>> /var/cccamlog/CCcam.log&安培;
其他回声的CCcam还行! >> /var/cccamlog/cccam.check
科幻
该脚本报告的CCcam还行!
但它没有运行,如果我搜索使用此命令的过程: PS X | grep的-v grep的|。grep的-c的CCcam
,我得到0,所以我知道这个过程是不是运行
有没有办法,我应该考虑任何其他因素可能会被愚弄检查脚本转换思维的CCcam运行?例如,莫不是某种程序崩溃后留下的标记/停止该脚本捡?
从另外一个测试,我得到..
错误:个CCcam仍具有PID运行:
如果-s的pidof&CCCAM GT;的/ dev / null的;然后
回声这已运行!
其他
回声的过程没有发现......
科幻
I am using this check script to see if a package called CCcam is running & restart it if it is not..
#!/bin/sh
process=`ps auxwww | grep CCcam | grep -v grep | awk '{print $1}'`
if [ -z "$process" ]; then
echo "Couldn't find CCcam running. Restarting server-binary" >> /var/cccamlog/cccam.check
echo && date >>/var/cccamlog/cccam.check
/usr/local/bin/CCcam -d >> /var/cccamlog/CCcam.log &
else echo "CCcam is still OK!" >> /var/cccamlog/cccam.check
fi
The script is reporting "CCcam is still OK!"
But it is not running, If i search for the process using this command:
ps x |grep -v grep |grep -c CCcam
, I get 0 so I know the process is not running.
Is there any other factors that I should take into account that might be fooling the check script into thinking CCcam is running? For example, could there be some kind of tag left after the program crashes/stops that the script is picking up on?
From another test I get.. ERROR: CCcam still runs with pid:
if pidof -s CCCam > /dev/null; then
echo 'It is already running!'
else
echo 'process not found...'
fi
这篇关于脚本检查过程和放大器;重新启动程序如果没有找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!