cron usage

Isaac Dunham ibid.ag at gmail.com
Sat Jan 9 21:24:40 UTC 2016


On Sat, Jan 09, 2016 at 02:40:21PM -0500, David Henderson wrote:
> While this is simply just a proof of concept, I could not get this to
> run correctly.  It had to be an obvious two-step approach, so I
> created an initial root crontab and a small shell script to
> dynamically create it there afterwards based on the contents of
> /etc/cron.d.
> 
> Initial /var/spool/cron/crontabs/root:
> * * * * * /etc/cron.d/.cron.d
> 
> /etc/cron.d/.cron.d:
> #!/bin/sh
> cat /etc/cron.d/* > /var/spool/cron/crontabs/root
> echo "* * * * * $0" >> /var/spool/cron/crontabs/root
> 
> I can see that the actual /var/spool/cron/crontabs/root file continues
> to dynamically populate based on the contents of /etc/cron.d, however,
> none of the jobs listed in those files actually runs.  Here's a sample
> of what would be inside one of them:
> 
> * * * * * date > /tmp/test1.txt
> 
> I've also tried with and without usernames and is doesn't work either.
> Any thoughts?

Looking through the source code, I see:
- cron will re-examine user crontabs every hour
- cron will parse and delete cron.update every minute if it exists
- cron.update is created by 'crontab', and is a simple list of users
whose cron jobs need to be updated.

In your example, .cron.d would need to have this line at the end:
echo 'root' >> /var/spool/cron/crontabs/cron.update

If that's not the problem, I've got no ideas.

HTH,
Isaac Dunham


More information about the busybox mailing list