1

I need a simple way to run some script on reboot:

I read that @reboot in crontab can work, but looks like some linux does not accept it:

  • Does it work on debian 7 ?
  • Does it work on debian 8 ?
  • Does it work on debian 9 ?
yarek
  • 827
  • 5
  • 13
  • 22
  • 1
    It depends upon the particular variant of `cron` that you are using (not on the distribution). Most Debian have installed some variant of vixie cron. But you could install other variants, e.g. [mcron](https://www.gnu.org/software/mcron/manual/html_node/index.html). And the `init` process also changed with time. Recent Debian use [systemd](https://en.wikipedia.org/wiki/Systemd) – Basile Starynkevitch Nov 01 '17 at 06:44

1 Answers1

10

According to the man page of crontab (Section 5):

Instead of the first five fields, one of eight special strings may appear:

          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 * * * *".

Please note that startup, as far as @reboot is concerned, is the time when the cron(8) daemon startup. In particular, it may be before some system daemons, or other facilities, were startup. This is due to the boot order sequence of the machine.

Run man 5 crontab on Debian Wheezy to see the full page. (Or see it online)

It was never removed so it works on each later version, too.

Scrumplex
  • 203
  • 2
  • 8