Linux環境下定時重啟jar
阿新 • • 發佈:2020-10-21
需要執行的shell指令碼:
echo "重啟webSocket" pidlist=`ps -ef |grep SystemCommunication |grep -v "grep"|awk '{print $2}'` kill -9 $pidlist rm $webSocket_home/nohup.out nohup /home/software/jdk1.8.0_221/bin/java -jar /home/SystemCommunication.jar > /home/utry/nohup.out &
設定定時任務:
crontab -e 05 16 * * * /home/utry/webSocketStart.sh crontab-l 05 16 * * * /home/utry/webSocketStart.sh
檢視定時任務日誌:
tail -f /var/log/cron Oct 21 16:02:16 localhost crontab[12132]: (root) END EDIT (root) Oct 21 16:02:37 localhost crontab[12166]: (root) LIST (root) Oct 21 16:03:01 localhost crond[675]: (root) RELOAD (/var/spool/cron/root) Oct 21 16:03:01 localhost CROND[12249]: (root) CMD (/home/utry/webSocketStart.sh) Oct21 16:04:01 localhost crontab[12392]: (root) BEGIN EDIT (root) Oct 21 16:04:22 localhost crontab[12392]: (root) REPLACE (root) Oct 21 16:04:22 localhost crontab[12392]: (root) END EDIT (root) Oct 21 16:05:01 localhost crond[675]: (root) RELOAD (/var/spool/cron/root) Oct 21 16:05:01 localhost CROND[12503]: (root) CMD (/home/utry/webSocketStart.sh) Oct21 16:09:44 localhost crontab[12982]: (root) BEGIN EDIT (root) Oct 21 16:12:19 localhost crontab[12982]: (root) REPLACE (root) Oct 21 16:12:19 localhost crontab[12982]: (root) END EDIT (root) Oct 21 16:13:01 localhost crond[675]: (root) RELOAD (/var/spool/cron/root) Oct 21 16:14:07 localhost crontab[13419]: (root) BEGIN EDIT (root) Oct 21 16:14:38 localhost crontab[13419]: (root) REPLACE (root) Oct 21 16:14:38 localhost crontab[13419]: (root) END EDIT (root) Oct 21 16:14:41 localhost crontab[13456]: (root) LIST (root) Oct 21 16:15:01 localhost crond[675]: (root) RELOAD (/var/spool/cron/root)