怎么用ip地址做网站,成都市公园城市建设局网站,网站开发企业开发,二级建造师证书查询编写脚本
tomcatMonitor.sh
#!/bin/sh. /etc/profile
. ~/.bash_profile#首先用ps -ef | grep tomcat 获得了tomcat进程信息#xff0c;这样出来的结果中会包含grep本身#xff0c;
#因此通过 | grep -v grep 来排除grep本身#xff0c;然后通过 awk {print $2}来打印出要…编写脚本
tomcatMonitor.sh
#!/bin/sh. /etc/profile
. ~/.bash_profile#首先用ps -ef | grep tomcat 获得了tomcat进程信息这样出来的结果中会包含grep本身
#因此通过 | grep -v grep 来排除grep本身然后通过 awk {print $2}来打印出要找的进程id号
pid$(ps -ef|grep apache-tomcat-8.5.47 |grep -v grep | awk {print $2})
#echo $pidif [ -n $pid ];then echo tomcat进程ID为:$pid. 运行正常
else echo 进程不存在! Tomcat自动重启 cd /usr/local/apache-tomcat-8.5.47/bin/ ./startup.sh
fi 为脚本添加可执行权限
chmod ux tomcatMonitor.sh配置定时任务
*/30 * * * * /usr/local/tomcatMonitor.sh重启定时任务systemctl start crond