Cron Ignoring Changes in /etc/cron.d

Posted by – January 4, 2007

Ever edit a file in /etc/cron.d and notice that cron magical knows it needs to reload? We do it all the time at BitLeap and it works great. However, recently we noticed that when we used php’s fileputcontents function cron wasn’t reloading automatically like it did before. Turns out that when we edited the files by hand, our text editor (vim) was updating the modified time on the directory. But when we used the php function it was not updating the directory’s modified time. Simply added a call to the touch function made cron magical again. :-)

  • http://rhodesmill.org/brandon Brandon Craig Rhodes

    Thanks so much for this pointer — it helped me get my cron jobs running again! Oddly enough, cron my my modern (late-2011) Ubuntu install will notice a file-only change in mtime if the previous version of the crontab was valid; but if the crontab gets a syntax error or an invalid username in it and gets rejected, then only a directory mtime modification makes cron start paying attention to the file again.