脚本内容:java_check.sh
#! /bin/bash # if [ -z `pidof java` ]; then echo -e `date +%Y-%m-%d` `date +%R`. “33[31m33[1m(JAVA)Process does not exist! 33[0m” >> /data/logs/java_check.log /usr/local/tomcat/bin/startup.sh >/dev/null 2>&1 sleep 30 netstat -tnlp >> /data/logs/java_check.log echo -e “r” >> /data/logs/java_check.log fi
计划任务,十五分钟执行一次
一个监控java程序运行的shell
#!/bin/shexport J_LIB=/data/sms/lib;export CLASSPATH=.:$J_LIB/jtds-1.2.jar:$J_LIB/log4j-1.2.12.jar:$J_LIB/postgresql-8.1-404.jdbc3.jar;export JAVA_HOME=/usr/java/jdk1.5.0_05export JRE=/usr/local/jdk/jreexport SHELL=/bin/bashexport HOME=/data/sms#java check statusif /bin/ps ax | /bin/grep -v grep | /bin/grep "java XinTai"; then cd;else cd /data/sms/xintai; /usr/java/jdk1.5.0_05/bin/java XinTai >/dev/null &fi
定时执行可以保证 java XinTai可以一直在运行
新闻热点
疑难解答