Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

If I put a new script into /etc/cron.d/ how does the system know to insert it into the global crontab?

Do I need to restart a process to pick it up?

Does init run crontab every minute, and it'll get re-scanned then?

Does it use inotify and watch /etc/cron.d?

Couldn't find anything terribly obvious, and I've always wondered

share|improve this question

1 Answer 1

up vote 15 down vote accepted

From cron(8):

   Additionally,  cron  reads  the files in /etc/cron.d: it treats the files in
   /etc/cron.d as in the same way as the /etc/crontab file

   …

   cron then wakes up every minute, examining all stored crontabs, checking each com‐
   mand to see if it should be run in the current minute.  When  executing  commands,
   any  output  is  mailed  to  the owner of the crontab (or to the user named in the
   MAILTO environment variable in the crontab, if such exists).  The children  copies
   of  cron  running these processes have their name coerced to uppercase, as will be
   seen in the syslog and ps output.

   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.

Also note that cron doesn't "insert the contents of cron.d into the global crontab" - those are independent:

   However, they are independent of /etc/crontab: they do not, for example, inherit 
   environment  variable  settings  from it.
share|improve this answer
2  
So it'll check itself every minute, including /etc/cron.d/ –  Tom O'Connor Feb 9 '12 at 15:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.