Cron

From HalfgeekKB
Revision as of 06:39, 26 May 2005 by 129.6.84.38 (talk)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Setting up cron is simple. Embarrassingly simple. The embarrassing part is Googling a site with an example every single time one has to use it. Here is that information.

Setting up a crontab

Run

crontab -e

This will open up everyone's favorite editor (set EDITOR=vim if someone made a mistake ;-)) to edit the crontab file (actually, a temp file—the file is parsed for correctness as soon as you close it, and only committed if there were no errors).

The format is a quintuple of time coordinates, trailed by the command to be executed.

#Minute Hour    M.day   Month   Weekday Command
# 0-59   0-23    1-31    1-12    0-6
#                                0=Sun

Any given time coordinate can be entered as a single number, a comma-delimited list, hyphen-defined range or a * indicating all.

# 10:35am on every Monday, Tuesday, and Wednesday in February or August
35      10      *       2,8     1-3     /usr/bin/updatedb >/dev/null 2>&1

That's about all there is to it.