Score:2

How to know if crontab implements @reboot?

cn flag
dmx

according to crontab.guru, many functions like @reboot, @daily, @annually ... are not standard. Is there any way to know the one implemented on my system (Kubuntu 21.04) ? I have tried the man-page, but have no result.

Thank you

David avatar
cn flag
way to know the one implemented on my system ? ... I guess we are supposed to know what your system is?
raj avatar
cn flag
raj
The best way to check is just to try it. Use with `@reboot` something that you can easily check for, for example create a particular file. If it works, then `@reboot` is supported. BTW. According to this: https://askubuntu.com/questions/335615/does-ubuntu-support-reboot-in-crontab , `@reboot` is supported on Ubuntu at least since 16.04, so it should be supported on Kubuntu as well. Also try `man 5 crontab` and see if it mentions `@reboot`.
Score:7
hr flag

The supported "special strings" for time specification are listed in man 5 crontab:

   Instead  of the first five fields, one of eight special strings may ap‐
   pear:

          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.

If you don't believe the documentation for your system, then you may download the source (ex. apt-get source cron) and check the entry.c file:

cron-3.0pl1$ grep '!strcmp' entry.c
                if (!strcmp("reboot", cmd)) {
                } else if (!strcmp("yearly", cmd) || !strcmp("annually", cmd)){
                } else if (!strcmp("monthly", cmd)) {
                } else if (!strcmp("weekly", cmd)) {
                } else if (!strcmp("daily", cmd) || !strcmp("midnight", cmd)) {
                } else if (!strcmp("hourly", cmd)) {
fr flag
You can do it even without the source by executing `strings $(which crontab) | grep "reboot"`
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.