View Full Version : Adding crond and crontab
ajauberg
04-06-2008, 01:09 PM
I have successfully built a new firmware using the 2.2.1 SDK, adding a number of Busybox applications that are disabled by default. I am now struggling with understanding the structure of the SDK and were to put things:
1. I want to start the crond daemon at boot time, how do I accomplish this?
2. When I start crond it asks for the catalog /var/spool/cron/crontabs. This catalog is however non-persistent, and must be recreated at every boot. Could I use the /etc/crontabs instead, and how do I accomplish this?
3. There are two busybox folders, named Busybox and Busybox-1.6.1. The latter does not seem to be in use?
Any help greatly appreciated!
UBNT-keba
04-06-2008, 11:47 PM
1. Take a look to /usr/etc/rc.d/* scripts. There are some calls to scripts' files that are called from persistent dir if these files exist.
2. Configure crontab daemon to use /etc/persistent/crontabs. /etc/persistent directory is persistent and is saved by cfgmtd -w -p /etc or through the web by apply changes
3. Busybox-1.6.1 is not used yet but it is newer than used one (in directory busybox).
ajauberg
04-07-2008, 12:57 PM
2. Configure crontab daemon to use /etc/persistent/crontabs. /etc/persistent directory is persistent and is saved by cfgmtd -w -p /etc or through the web by apply changes
Thanks for the info, but it is not clear to me how I can configure the crontabs daemon. If I place it in the /usr/etc/startup.list there is no room for parameters?
UBNT-keba
04-07-2008, 10:27 PM
Hi,
You have to do something like this:
Put your crontab daemon exec line with parameters into /etc/persistent/rc.poststart file. So it will be executed after system boots up. Do not forget to send daemons to background to avoid system boot blocking.
/etc/persistent/rc.poststart sample:
echo "SHELL=/bin/sh" > /etc/crontab
echo "PATH=/sbin:/bin:/usr/sbin:/usr/bin" >> /etc/crontab
echo "# m h dom mon dow user command" >> /etc/crontab
echo "17 * * * * ubnt echo 'DONE SOMETHING'" >> /etc/crontab
/sbin/cron &
Just try. We are not using cron so I don't know what is exact parameters and crontab syntax has to be used.
Good luck
ajauberg
04-12-2008, 12:05 PM
This is the code I came down to to make crond running. The following is the contents of the /etc/persistent/rc.poststart file that is called by the framework:
#!/bin/sh
mkdir /var/spool
mkdir /var/spool/cron
mkdir /var/spool/cron/crontabs
echo "*/5 * * * * <add your cron commands here>" >> /var/spool/cron/crontabs/ubnt
crond
drwho17
05-22-2009, 07:25 PM
This is the code I came down to to make crond running. The following is the contents of the /etc/persistent/rc.poststart file that is called by the framework:
#!/bin/sh
mkdir /var/spool
mkdir /var/spool/cron
mkdir /var/spool/cron/crontabs
echo "*/5 * * * * <add your cron commands here>" >> /var/spool/cron/crontabs/ubnt
crond
susanspy
05-28-2009, 11:01 AM
hello all,
i am susan here, thanksa for informative post, please do some more informative post here.
thanks a lot
cheers!!!!!!!!!!!!!!!!!
EzioO
12-20-2011, 05:10 AM
I found a strange cron behaviour on NanoStations M2 running AirOs 5.3.3
1) crond process is running
2) crontab is correctly configured
3) nothing happens
If I do minor changes in crontab (crontab -e) such as adding-removing a meaningless task or change the output redirection and/or restart crond and/or a mix of the two operation, after a few attempts my cron-ed tasks start working.
It looks rather weird to me, is there any "rule" I should follow to make cron work without any tampering, "out-of-the-box"?
Thanks,
Ezio