OpenWrt Forum Archive

Topic: How to set cron jobs using uci?

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

I set some scripts to run using `crontab -e`, but these get lost after a reboot. A comment in /etc/crontabs/root says uci generates cron entries from /etc/config/crontabs. What is the syntax for this file? I tried putting regular cron entries there, but `uci commit` failed with parse errors.  I searched the wiki/forums but couldn't find any docs. Thanks for any help.

(Last edited by mfyahya on 20 Dec 2009, 12:22)

I also couldn't find anything describing the crontab format for /etc/config/crontabs but discovered the Xwrt web interface knew how to, give it a try.
An example I'm using to (hopefully) keep my WLAN working:

config 'crontab'
    option 'minutes' '*/10'
    option 'hours' '*'
    option 'days' '*'
    option 'months' '*'
    option 'weekdays' '*'
    option 'command' '/etc/checkWLAN'
    option 'enabled' '1'

how true is this in backfire... I canst seem to get this working

root@OpenWrt:/vol/vol0/backup/log# cat /etc/config/crontabs 
config 'crontab'
        option 'minutes' '0'
        option 'hours' '2'
        option 'days' '*'
        option 'months' '*'
        option 'weekdays' '*'
        option 'command' '[ -x /vol/vol0/backup/bin/backUpRoot ] && /vol/vol0/backup/bin/backUpRoot > /dev/null 2>&1'
        option 'enabled' '1'

wont work...

(Last edited by ghatothkach on 7 Nov 2011, 18:46)

The /etc/config/crontabs file is part of X-Wrt, its not present in standard OpenWrt, simply use /etc/crontabs/root there.

The discussion might have continued from here.