Wednesday, January 16, 2013

Restart JAVA Process in crontab


Following is a shell script which can be used for restart JAVA application. If Application active count is zero(0), then this script can be used to restart the process. This shell script can be called by a crontab.

cat /dev/null > nohup.out
PRGCOU=`ps -eaf|grep JAVAApp.jar |grep -v grep |wc -l`

if [ $PRGCOU -eq 0 ]
then
nohup java -Xms32m -Xmx64m -jar JAVAApp.jar &
sleep 3
exit
fi