#这个程序功能很实用,目的是监控我的三个java jar包,三十秒查询一次,
#哪个程序跪了,就重启哪个程序
#!/bin/bash
while true
do
down=` ps -aux |grep -w down.jar |grep -v grep|wc -l`
readdown=` ps -aux |grep -w readdown.jar |grep -v grep|wc -l`
downzpToFnish=` ps -aux |grep -w downzpToFnish.jar |grep -v grep|wc -l`
if [ $down -eq 0 ];
then
nohup java -jar /root/down.jar /mnt/mydisk/down/ > /root/down.log 2>&1 &
else
echo "down.jar Alive"
fi
if [ $readdown -eq 0 ];
then
nohup java -jar /root/readdown.jar > /root/readdown.log 2>&1 &
else
echo "readdown.jar still alive"
fi
if [ $downzpToFnish -eq 0 ];
then
nohup java -jar /root/downzpToFnish.jar /mnt/mydisk/zpdown/ > /root/zp.log 2>&1 &
else
echo "downzpToFnish.jar still alive"
fi
sleep 30
done
~
【shell-01】 守护java进程
于 2019-09-24 10:25:00 首次发布