Linux Tomcat运行监测

Tomcat 莫名其妙关闭了,暂时还没有找到原因,先写个监测脚本

#!/usr/bin/env bash
  
function check(){
        APPNAME=$1
        DATE=$(date "+%Y-%m-%d %H:%M:%S")
        PID=`ps -ef |grep java|grep $APPNAME|grep -v grep|awk '{print $2}'`
        if [ x"$PID" == x"" ]; then
# service 一定要完整路径
/usr/sbin/service $APPNAME start echo "$DATE start $APPNAME success ... " # else # echo "$DATE $APPNAME is running ..." fi } check console check server-A check server-B

配置crontab -e

*/1 * * * * /bin/sh /usr/local/shell/checktomcat.sh >> /data/wwwlogs/checktomcat.log

 

posted @ 2021-11-18 22:17  rubekid  阅读(56)  评论(0编辑  收藏  举报