Scheduling Cron job-Problem

Hello All,

I want to run a script for every 5 minutes interval.So i developed a script which has to be scheduled to run for every 5 minutes. That script internally runs another script. But the problem is it is not executing properly. Can anybody throw some light on this.

Below are the code snippets for the two scripts.

the first script FirstScript.sh

LogMessage ()
################################################################################
# #
# Write message to log file. #
# #
################################################################################
{
echo "`date` - ${*}" >> $path/applicationLogFile.log
}

ps -e |grep "SecondS*"
scriptStatus=$?
if [ -f $inputfile ]
then
if [ $scriptStatus -ne 0 ]
then
LogMessage "The input file is found."
LogMessage "Initiating RVPMIG2X script"
sh $path/RVPMIG2Xdummy.sh
else
LogMessage "The script is already running.Can not initiate again"
fi
else
LogMessage "The input file is not found"
fi

My SecondScript.sh is as follows:

#! /bin/ksh
echo "Starting the dummy script."
sleep 620
echo "Ending the Script."

Though my second script sleeps for 620 seconds that means for about more than 10 mins but the inner else block is never getting invoked.

i set the cron job as

0,5,10,15,20,25,30,35,40,45,50,55 * * * * sh FirstScript.sh.

when i run the FirstScript normally it is working perfectly fine but when i put it in cron job it is not. Can anybody tell me for this erratic behaviour?

Thanks a lot in advance.

RSC1985

---------- Post updated at 02:44 AM ---------- Previous update was at 02:43 AM ----------

In the code snippet instead of RVPMIG2Xdummy.sh please treat it as SecondScript.sh

what error you are getting? (cron logs?)

I'm not getting any error.All the time it logs the messages

The input file is found.
Initiating RVPMIG2X script

though the script is still running it is entering into if block logs the above messages.

---------- Post updated at 06:20 AM ---------- Previous update was at 03:33 AM ----------

Can anyone suggest me a way to resolve this issue?

Hi,

Can you provide the output of the ps -e |grep "SecondS*" command when the SecondScript.sh is running ?
Personally I would use "ps -ef | grep SecondScript | grep -v grep".
It can be that the "ps -e" output from the user shell and that of the cron shell is different.

E.J.

Where is $path set ?
Where are the scripts located? Are they in the root directory?