写个简单的定时重启,弄了一上午,主要是crontab里面奇怪
#!/bin/bash p=`ps -ef |grep tomcat |head -n 1|awk -F" " ‘{print \$2}‘` /usr/local/tomcat/bin/shutdown.sh sleep 10s p2=`ps -ef |grep tomcat|grep -v "grep"|wc -l` if [ $p2 -ne 0 ];then echo "正在kill杀进程" kill $p fi /usr/local/tomcat/bin/startup.sh
crontab里:26 12 * * * /bin/sh /lile/monitor.sh &> /lile/ll.log
crontab里要是这样写为什么,等定时任务结束后,tomcat进程也自动结束了????????????????
26 12 * * * export DISPLAY=:0.0 ;gnome-terminal -x /bin/bash -c "/lile/monitor.sh &> /lile/ll.log"
时间: 2024-10-12 01:59:33