Cron job skipping problem

Hi,
I have a crontab that runs some shell scripts at fixed intervals. Although, one condition for a script to continue is that a previous instance of the same script should have terminated. But, inspite of the fact that the old instance has finished execution, the new instance still terminates.

My grep statement to find any previous instances is like:
ps -ef |grep "/usr/bin/ksh /yantra/utya518/wmshome/cron/moto_wo_09_19_dwl.sh" | grep -v grep | wc -l | read instances

I then echoed out the grep results, and found that the current instance had spawned a child, that executed the same script!

cronyan 1562 1468 0 23:34:01 ? 0:00 /usr/bin/ksh /yantra/utya518/wmshome/cron/mo
to_wo_09_19_dwl.sh

cronyan 1468 1275 0 23:34:01 ? 0:00 /usr/bin/ksh /yantra/utya
518/wmshome/cron/moto_wo_09_19_dwl.sh

Although, this behaviour is not repeated on every run.

Please help me find out why this is occuring

Thanks!

Puneet Arora

check ...

  1. swap space ... got enough?

  2. file count in output directory ... got too much?

  3. disk space in target filesystem ... got enough?

Rather than the long process list check, why not use a lock file and check for its existence? ie, if it exists, there's another process running, so don't run. Just be sure to include a trap for removing the file for all termination possibilities:

trap 'rm -f $LOCKFILE' 0 1 2 3 13 14 15

Cheers,

Keith

the lock file, however, will not fix the cause of the script's abnormal behavior ... a server that's causing a script to behave differently from what it normally does is indicating that it has a problem that needs to be resolved ... not heeding the hint may fix the issue only for the time being but may cause larger issues later ...

besides --- how can the lock file stop the earlier run from running long? if the earlier script run is stuck on a process because of lack of computing resources in the server, what will happen to the subsequent script runs? would it then be acceptable that instead of running the script 4 times a day, the script only gets to run once every 2 days or some other longer frequency than what was intended?