Does anyone have any idea how to force cron to reload its user-based crontabs?
I have a setup script for a system which does a lot of things, amongst them copying a crontab into /var/spool/cron/crontabs and settings its permissions, however cron ignores it until I crontab -e and make a change (eg add and delete something) and save it. Restarting cron or even the box is not sufficient to make it reload.
I discovered that the mtime of the crontabs folder is relevant, but "touch"ing it hasn't solved the problem.
(System is Ubuntu 8.04 server.)
On 17-Sep-08 16:56:22, Mark Rogers wrote:
Does anyone have any idea how to force cron to reload its user-based crontabs?
I have a setup script for a system which does a lot of things, amongst them copying a crontab into /var/spool/cron/crontabs and settings its permissions, however cron ignores it until I crontab -e and make a change (eg add and delete something) and save it. Restarting cron or even the box is not sufficient to make it reload.
I discovered that the mtime of the crontabs folder is relevant, but "touch"ing it hasn't solved the problem.
(System is Ubuntu 8.04 server.)
Does the following (from 'man cron') give any useful clue?
cron then wakes up every minute, examining all stored crontabs, checking each command to see if it should be run in the current minute. [...]
Additionally, cron checks each minute to see if its spool directory's modtime (or the modtime on /etc/crontab) has changed, and if it has, cron will then examine the modtime on all crontabs and reload those which have changed. Thus cron need not be restarted whenever a crontab file is modified. Note that the crontab(1) command updates the modtime of the spool directory whenever it changes a crontab.
Hoping this helps, Ted.
-------------------------------------------------------------------- E-Mail: (Ted Harding) Ted.Harding@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 17-Sep-08 Time: 19:04:33 ------------------------------ XFMail ------------------------------
(Ted Harding) wrote:
Does the following (from 'man cron') give any useful clue? [..snip..]
Additionally, cron checks each minute to see if its spool directory's modtime (or the modtime on /etc/crontab) has changed, and if it has, cron will then examine the modtime on all crontabs and reload those which have changed. Thus cron need not be restarted whenever a crontab file is modified. Note that the crontab(1) command updates the modtime of the spool directory whenever it changes a crontab.
It was the modtime of the /var/spool/cron directory I was changing in my script (not the crontabs subdirectory as previously indicated) which I think is what "man cron" is referring to (that's where I got the info too). It didn't occur to me to try changing the mtime of /etc/crontab however; I'll give that a go.