Script Cron issue

Hi All.

I have scheduled the script below in cron (Solaris 8). This script is supported to monitor the output of the websphere was-stat command and send a page out if it finds that one of the JVMs in the JVM_list.txt is down.

#!/bin/ksh
mailbox=pager_name
cat JVM_list.txt | while read i
do
was-stat | grep $i > /dev/null 2>&1
if [ $? -ne "0" ]; then
mailx -s "The JVM $i is down on server `hostname`" $mailbox
##echo "The JVM $i is down on server `hostname`"
else
echo " The JVM $i is up on the server `hostname`"
fi
done

The Cron entry is as follows

05 * * * 1-5 /path/to/script/jvmscript/server_name_jvm_monitor.sh > /dev/null 2>&1

The issue is that if I run the script interactively, it works.
but crontab does not seem to be initiating the script as I tried bringning a JVM down and I did not recieve a page.
The script is supposed to run every 5 mins on weekdays.
Can someone look at it and the script and help me debug.

Thanks
Segwar

Better first check whether its really not initiating or causing some error.

05 * * * 1-5 /path/to/script/jvmscript/server_name_jvm_monitor.sh >> /some/path/script.log 2>&1 

At least we would have a direction whats going wrong.

Thanks Anchal,

Leme do that.Will get back to you!!

Peace!!

cron will be running with minimal number of environment variables loaded.

  1. Make sure that you have sourced the .profile or the necessary variables in the script

  2. Inorder to run the script every 5 minutes, you need to use

00,05,10,15,20,25,30,35,40,45,50,55 * * * 1-5 /path/to/script/jvmscript/server_name_jvm_monitor.sh >> /some/path/script.log 2>&1 

or

  */5 * * * 1-5 /path/to/script/jvmscript/server_name_jvm_monitor.sh >> /some/path/script.log 2>&1 
*/5 * * * 1-5 /path/to/script/jvmscript/server_name_jvm_monitor.sh > /dev/null 2>&1

Tahnks Everyone.

It seems that I was making multiple mistakes in teh script.

Thanks all for the prompt replies.

Segwar