vixie-cron and the 7 meta specifications that most people dont know about

by Karanbir Singh Email

Although its in the man page, most people don't know that you can specify schedules using one of these meta specs :

@reboot : Run once after reboot.
@yearly : Run once a year, ie. "0 0 1 1 *".
@annually : Run once a year, ie. "0 0 1 1 *".
@monthly : Run once a month, ie. "0 0 1 * *".
@weekly : Run once a week, ie. "0 0 * * 0".
@daily : Run once a day, ie. "0 0 * * *".
@hourly : Run once an hour, ie. "0 * * * *".

So if one of those fits the requirements, use it. At the very least, you end up with better readability. And because users can set these on their own, it allows them to create jobs and services that come online on machine reboot. Without there being any need for them to get access to the system initscripts. Easy win for a problem that comes up quite a few times and in many places.

Now someone needs to make puppet be aware of these!

- KB

4 comments

Comment from: Raoul [Visitor] Email
Raoul@reboot : Run once after reboot and after service crond restart
28/Sep/2010 @ 08:10
Comment from: Mark [Visitor]
MarkBut, isn't "0 * * * *" more readable then @hourly? I mean, hourly can mean at 46 minutes past the hour, every hour....

With "0 * * * *" I know exactly when it is supposed to run!

I guess it's just a matter of preference :-)
29/Sep/2010 @ 02:49
Comment from: Nils Breunese [Visitor]
Nils Breunese@Raoul: 'man 5 crontab' says (at least on CentOS 4 and 5):

----
@reboot : Run once, at startup.
----

I also tested this and the command doesn't seem to be executed on just a 'service crond restart'.
29/Sep/2010 @ 05:08
Comment from: Karanbir Singh [Member] Email
Karanbir SinghNils,

the @reboot: will run when the machine reboots/ boots. Not when cron restarts.
29/Sep/2010 @ 05:56

This post has 67 feedbacks awaiting moderation...

Comments are closed for this post.