cron timing shortcuts

I had occasion to discover this recently–I’ve used cron for years, but never knew this!

You can shortcut some of the times you might commonly use in your crontab in Debian (and, most-likely, in other distros).  For instance:

  • @yearly
  • @annually
  • @monthly
  • @weekly
  • @daily
  • @midnight
  • @hourly

All of these is equivalent to a “standard” time:  @hourly, for instance, is the same as saying “0 * * * *”, et cetera.

That’s cool as heck, of course, but the one that really wowed me was this one:  @reboot.  This will let a non-privileged account run something at startup, WITHOUT it having to be in /etc/init.d!  Use it like so:

@reboot <your script reference here>

Nice trick, that!

2 Responses to cron timing shortcuts

  1. wizzyrea says:

    Great tips! I had no idea!

  2. atz says:

    Like almost all cronisms, this also inevitably breaks on old versions and certain distros (like BSD or Solaris). Check your man pages to be sure.