CRON issue

Rick Stevens rstevens at vitalstream.com
Wed Mar 14 17:45:21 UTC 2007


On Wed, 2007-03-14 at 16:41 +0000, Tech Guy wrote:
>   
> Hello,
> 
> I am trying to troubleshoot a CRON issue : CRON doesn't run my scripts
> but when run outside the CRON, the script runs perfect.(The same
> script was running since a year and suddenly it stopped since a month.
> Nothing got changed in the script or the env). The OS is RHAS 3.0,
> update 8.
> 
> To troubleshoot further, I wrote a small script to output the date
> command which is as below
> 
> vi test.sh
> -----------------------------------
> #!/bin/bash
> /bin/date > /home/test/test.out
> -----------------------------------
> then I added entries in the CRON:
> 
> 15 10 * * * /home/test/test.sh > /home/test/testcron.out 2>&1
> -----------------------------------
> 
> The CRON again doesn't seem to be running the script. The script
> worked fine when I execute it from the command propmt $ ./test.sh
> 
> Has anyone experienced this kind of issues before. I verified the
> environment too but still cannot figure out the cause.
> 
> I appreciate your response.

Make sure that /home/test/test.sh is executable:

	chmod 755 /home/test/test.sh

Doing a "./test.sh" forces the system to execute it and might mask
the crontab error.  I'm assuming this is in root's crontab, so check
root's mail to see if cron reported an error.  By default cron will send
an email to the owner of the crontab when an error occurs.

Your crontab entry should not have a space between the ">" and the
"/home/test/testcron.out":

    15 10 * * * /home/test/test.sh >/home/test/testcron.out 2>&1

Also note that the cron job as shown only runs the script once, at
10:15 a.m.  For testing purposes, you might try "5 * * * *" to run it
every 5 minutes until you sort it out, then go back to the original
schedule.  Just a thought.
----------------------------------------------------------------------
- Rick Stevens, Principal Engineer          rstevens at vitalstream.com -
- VitalStream, Inc.                       http://www.vitalstream.com -
-                                                                    -
-     If one is what one eats, then I am fast, cheap and greasy!     -
----------------------------------------------------------------------




More information about the Redhat-install-list mailing list