cron.d 如何通知系统?

Tom*_*nor 16 cron

如果我将一个新脚本放入/etc/cron.d/系统如何知道将其插入到全局 crontab 中?

我是否需要重新启动一个进程来接收它?

是否init每分钟运行一次 crontab,然后它会被重新扫描?

它使用 inotify 和 watch/etc/cron.d吗?

找不到任何非常明显的东西,我一直想知道

Mik*_*eyB 20

来自 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.
Run Code Online (Sandbox Code Playgroud)

另请注意,cron 不会“将 cron.d 的内容插入到全局 crontab 中”——它们是独立的:

   However, they are independent of /etc/crontab: they do not, for example, inherit 
   environment  variable  settings  from it.
Run Code Online (Sandbox Code Playgroud)

  • 所以它会每分钟检查一次,包括`/etc/cron.d/` (5认同)