应用是通过nohup java -jar xx.jar &
难免遇到unkown error 挂掉,所以有必要编写看门狗 保护一下
#!/bin/bash
date ‘+%Y-%m-%d %H:%M:%S’`
now=
grepFlag=’datawarehouseLoader.jar’
thisLog=’/loader/watchDogLog.log’
baseDir=”/loader/”
sleepTime=60
if [ ! -f “
exit
fi
user=”root”
if [ “$user” != “root” ]; then
echo “this tool must run as root”
exit
fi
while [ 0 -eq 0 ]
do
now=date '+%Y-%m-%d %H:%M:%S'
ret=ps -ef | grep "$grepFlag" | grep -v grep | wc -l
if [
echo “
nohup java -jar datawarehouseLoader.jar &
echo “
cd
sleep $sleepTime
fi
done
`
臭不要脸的参考自:使用bash shell脚本编写简易的看门狗watch dog – https://www.chenyudong.com/archives/bash-shell-watch-dog-auto-restart-process.html