欢迎来到李先生的博客

深山的鹿,不知归处;万般皆苦,只可自渡。
扩大
缩小

定时重启tomcat

写个简单的定时重启,弄了一上午,主要是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"

 

posted on 2017-04-11 14:07  Captain_Li  阅读(781)  评论(0编辑  收藏  举报

导航