Script content: 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
netstat-tnlp >>/data/logs/java_check.log
echo-e "R" >>/data/logs/java_check.log
fi
Scheduled task, 15 minute execution
Copy Code code as follows:
*/15 * * * * root/usr/local/bin/java_check.sh
a shell that monitors the running of Java programs
#!/bin/sh
export 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_05
export jre=/usr/local/jdk/jre
export Shell=/bin/bash
Export Home=/data/sms
#java Check status
if/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
Timed execution ensures that the Java Xintai can be run all the time