I have a Java application running in the background which process looks like this.
java -DMyService=Y -DWorkingDir
And I have a monitoring script which looks like this;
count_service=`ps -aef | grep MyService | wc -l`
if [ count_service -lt 2 ] ; then
echo "Service_Stopped on `date`" >> $servicelog
fi
Although the service keeps on running, sometimes, I got the message in my log that the service has stopped. Is there something wrong with my monitoring script? To my knowledge, it should be 2; one for Java and another is for grep.