In che modo cron.d notifica al sistema?


16

Se inserisco un nuovo script in che /etc/cron.d/modo il sistema sa inserirlo nel crontab globale?

Devo riavviare un processo per raccoglierlo?

Non initcorrere crontab ogni minuto, e si metterà a ottenere ri-scansione allora?

Usa inotify e guarda /etc/cron.d?

Non sono riuscito a trovare nulla di terribilmente ovvio, e mi sono sempre chiesto

Risposte:


20

Da 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.

Nota anche che cron non "inserisce il contenuto di cron.d nel crontab globale" - quelli sono indipendenti:

   However, they are independent of /etc/crontab: they do not, for example, inherit 
   environment  variable  settings  from it.

5
Quindi controllerà se stesso ogni minuto, incluso/etc/cron.d/
Tom O'Connor
Utilizzando il nostro sito, riconosci di aver letto e compreso le nostre Informativa sui cookie e Informativa sulla privacy.
Licensed under cc by-sa 3.0 with attribution required.