crontab @reboot 在 debian 7 上工作吗?

yar*_*rek 1 debian cron reboot

我需要一种简单的方法来在重新启动时运行一些脚本:

我读到 crontab 中的 @reboot 可以工作,但看起来有些 linux 不接受它:

  • 它适用于 debian 7 吗?
  • 它适用于 debian 8 吗?
  • 它适用于 debian 9 吗?

Scr*_*lex 10

根据crontab(第 5 节)的手册页:

可能会出现八个特殊字符串之一,而不是前五个字段:

          string         meaning
          ------         -------
          @reboot        Run once, at startup.
          @yearly        Run once a year, "0 0 1 1 *".
          @annually      (same as @yearly)
          @monthly       Run once a month, "0 0 1 * *".
          @weekly        Run once a week, "0 0 * * 0".
          @daily         Run once a day, "0 0 * * *".
          @midnight      (same as @daily)
          @hourly        Run once an hour, "0 * * * *".
Run Code Online (Sandbox Code Playgroud)

请注意,startup 就@reboot 而言,是 cron(8) 守护进程启动的时间。特别是,它可能在某些系统守护程序或其他设施启动之前。这是由于机器的启动顺序。

man 5 crontab在 Debian Wheezy 上运行以查看完整页面。(或者在网上看

它从未被删除,因此它也适用于每个更高版本。