开机启动java

linux 2584 2022-06-16 06:07

crontab -e

service crond restart

 

 

* * * * * . /etc/profile;/bin/sh /root/start8080.sh

*/30 * * * * sh /root/clear.sh

 

 

 

 

#!/bin/sh
 
#切换到目录
cd /opt/blog
date=`date`
 
#查询端口占用
lsof -i:8080
 
# $? -ne 0 不存在 $? -eq 0存在 
if [ $? -ne 0 ]
then
    nohup java -jar rs0322-blog.jar >/opt/blog/nohup.out &
    echo $date  ":=============== restart ===============" >> nohup.log
else
    echo $date  ":=============== is normal ==============" >> nohup.log
fi

文章评论