新建脚本,里面键入如下内容
#!/bin/sh
DTTERM=`ps -ef |grep tomcat |wc -l`
rq=`date +%Y-%m`
frq=`date +%Y-%m-%d`
minTime=`date +%H:%M`
tomcatLog=/md/server_log/tomcat/$rq
if [ $DTTERM == 1 ]
then sh /md/apache-tomcat-6.0.20/bin/startup.sh
if [ ! -d \"$tomcatLog\" ]; then
mkdir -p \"$tomcatLog\"
fi
echo \"tomcat restart at $frq $minTime\" >> $tomcatLog'/'$frq'.log'
else
if [ ! -d \"$tomcatLog\" ]; then
mkdir -p \"$tomcatLog\"
fi
echo \"tomcat ok at $frq $minTime\" >> $tomcatLog'/'$frq'.log'
fi
加入到crontab中自动启动
#授权
chmod 777 /home/xx/server_start.sh
#编辑每隔5分钟运行一次脚本
crontab -e
#会打开编辑脚本,里面键入如下命令
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /home/xx/server_start.sh
#重新启动crontab服务
/ect/init.d/crond restart
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- dfix.cn 版权所有 湘ICP备2024080961号-1
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务