shell监控脚本
#!/bin/bash export LANG=C.UTF-8 CALL=checkCoin.jar CALL_port=8721 callweb=`netstat -ant | grep $CALL_port | awk '{print $4}' | awk -F : '{print $4}'` calllog=/d/workspace/checkCoin/checkCoin.log date=`date +%Y-%m-%d.%H:%M` dir=/d/workspace/checkCoin if [ $callweb = $CALL_port ] then echo "call is running" else echo "the call service alredy restart" echo "$date the call service alredy restart" >> $calllog nohup java -jar $dir/$CALL --spring.profiles.active=prd --server.port=$CALL_port > $dir/checkCoin.log 2>&1 & sleep 15 echo $date call aleady restart | mail -v -s "call restart" 1402026297@qq.com fi
定时启动
crontab -e
select-editor
*/1 * * * * bash /d/workspace/listen.sh
crontab -l 查看服务