shell脚本调度 Tomcat 启动、停止

Tomcat启动:

shell脚本调度tomcat时,必须将java home添加到环境变量中,否则无法调用成功

#!/bin/bash
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_231
echo "The execute stime is:"`date` >> execute.log
sh /root/apache-tomcat-7.0.94/bin/startup.sh

Tomcat停止:

用tomcat自带的shutdown.sh有时不起作用,采用杀进程的方式比较稳妥

#!/bin/bash
echo "The execute etime is:"`date` >> execute.log

ps -ef | grep /root/apache-tomcat-7.0.94/bin | grep -v grep | awk  '{print $2}'| xargs kill

你可能感兴趣的:(shell脚本调度 Tomcat 启动、停止)