#!/bin/bash
DATE=`date +%Y-%m-%d-%H-%M-%S`
echo "當前時間是:$DATE"
# 根據(jù)端口號查找進程
PID=`/usr/sbin/lsof -i:9002 |/usr/bin/awk 'NR==2{print $2}'`
echo "殺死當前Bootstrap進程pid:$PID"
kill -9 $PID
# 根據(jù)實際情況修改路徑
echo "啟動tomcat進程"
/usr/bin/bash /usr/java/apache-tomcat-9.0.20/bin/startup.sh
echo "等待20秒"
sleep 20
PID=`/usr/sbin/lsof -i:9002 |/usr/bin/awk 'NR==2{print $2}'`
echo "啟動tomcat進程后的pid是:$PID"
echo "========================================================="
# crontab -l
# 每天凌晨四點重啟一次后臺服務
# 0 4 * * * /root/definite_time_restart.sh >> /var/log/reboot_time.log 2>&1
?
?
?
?
本文摘自 :https://blog.51cto.com/u