Prefetch Technologies // Keeping your cache lines cozy

Useful crontab short cuts

While reading through crontab(5) this morning I came across this useful nugget of information:

"These special time specification "nicknames" are supported, which replace the 5 initial time and date fields, and are prefixed by the @ character"

This translates into the following known time periods:

@reboot : Run once, at startup.
@yearly : Run once a year
@annually : Run once a year
@monthly : Run once a month
@weekly : Run once a week
@daily : Run once a day
@hourly : Run once an hour

So instead of writing:

0 * * * * command

You can specify hourly to accomplish the same thing:

@hourly command_to_run

Or if you want to run something when a machine is rebooted you can add this:

@reboot echo "" | mail -s "/bin/hostname was recently rebooted" root

Several of these short cuts are rather handy and it makes things easier to read IMHO. Gotta love short cuts!