OpenWrt Forum Archive

Topic: Getting cron jobs to run

The content of this topic has been archived on 22 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi,

I added a couple of lines containing scripts in CRONTAB that if I call them directly they run.  They seem to be ignored in the /etc/crontabs/root file.  The entries are:

/15 8,9,10,11,12,13,14,15,16,17 * * 1,2,3,4,5 /bin/sh /www/cpy2web.sh
/5   8,9,10,11,12,13,14,15,16,17 * * 1,2,3,4,5 /bin/sh /www/cpy2tmp.sh


Security is set up on both as:

-rwxr-xr-x


PS AUX shows: 

/usr/sbin/crond

This is on a WL-500gP.  Is there a log entry for CRON jobs?  Anyone have a clue how I can find out why it is not working?

Thanks,
Rich

I think that you should enable crontabs first!
/etc/init.d/S60cron start

And make sure you enabled the service:

/etc/init.d/S60cron enable

I believe it is started already because if I do a

         /etc/init.d/S60cron start

it tells me that it is started already and I see it when I do a

         ps aux

I see the following

          /usr/bin/crond

flowersrj wrote:

/15 8,9,10,11,12,13,14,15,16,17 * * 1,2,3,4,5 /bin/sh /www/cpy2web.sh
/5   8,9,10,11,12,13,14,15,16,17 * * 1,2,3,4,5 /bin/sh /www/cpy2tmp.sh

Is the / a valid option i the time-table? Don't you mean *5 and *15?

Actually it is */15 and */5.  It is now working.

Thanks for the clue !!

Now I have got what's below and it is working....

*/15 8-17 * * 1-5 root /www/cpy2web.sh
*/5   8-17 * * 1-5 root /www/cpy2tmp.sh

The problem is that difference places on web describe CRON/CRONTAB line definition differently.

(Last edited by flowersrj on 20 Sep 2007, 14:14)

Yo are right it is */5.... one hand helps the other.... (probably not a english saying)

I have enabled logging and now I can see the CRON jobs fire off in the log but they still don't seem to be running.  Here's the CRON entry and the script's contents.  It works if I call script directly from the command line but not from CRON.

Sample log entry is ...

Sep 20 12:47::35 (none) kern.notice crond[736]: USER root pid 978 cmd root /rom/bin/sh /www/cpy2tmp.sh

cron entry ...

*/5 8-17 * * 1-5 root /rom/bin/sh /www/cpy2tmp.sh

/www/cpy2tmp.sh contents is ...

#!/bin/sh
cp /tmp/SpcaPict/jpg /tmp/SpcaWeb.jpg

Any ideas?
-Rich

I would change the line to


*/5 8-17 * * 1-5 /www/cpy2tmp.sh

Traced the problem to the inclusion of 'root' in the entry.  Seems its not used in OpenWRT.  Everything is working as it should. :-)

Thanks for all your help,
Rich

The discussion might have continued from here.