服务器定时任务

1、jar启动脚本

start.sh文件:

#!/bin/bash
timeNow=$(date "+%Y-%m-%d %H:%M:%S")
echo $timeNow":start springboot_quick2-0.0.1-SNAPSHOT.jar..."
kill -9 $(ps -ef | grep springboot_quick2-0.0.1-SNAPSHOT.jar | grep -v grep | awk  '{print $2}' | xargs)
nohup /usr/local/java/jdk1.8.0_192/bin/java -jar /data/quick_0/springboot_quick2-0.0.1-SNAPSHOT.jar >>/data/quick_0/log.txt 2>&1 &
                                                                                                                               

 

 注意:这里jdk的路径最好用绝对路径,不然会失效

 

 参考:https://blog.csdn.net/capecape/article/details/78515558?utm_medium=distribute.pc_relevant.none-task-blog-baidujs-3

posted @ 2020-10-19 10:21  suke_123  阅读(416)  评论(0编辑  收藏  举报