#!/bin/bash
DATE=`date +%Y-%m-%d-%H-%M-%S`
echo "當(dāng)前時(shí)間是:$DATE"
# 根據(jù)端口號(hào)查找進(jìn)程
PID=`/usr/sbin/lsof -i:9002 |/usr/bin/awk 'NR==2{print $2}'`
echo "殺死當(dāng)前Bootstrap進(jìn)程pid:$PID"
kill -9 $PID
# 根據(jù)實(shí)際情況修改路徑
echo "啟動(dòng)tomcat進(jìn)程"
/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 "啟動(dòng)tomcat進(jìn)程后的pid是:$PID"
echo "========================================================="
# crontab -l
# 每天凌晨四點(diǎn)重啟一次后臺(tái)服務(wù)
# 0 4 * * * /root/definite_time_restart.sh >> /var/log/reboot_time.log 2>&1
?
?
?
?
本文摘自 :https://blog.51cto.com/u