Scheduling Tasks
Like other flavors of Unix, Mac OS X uses cron
to schedule tasks for periodic execution. Each
user’s
cron
jobs are controlled by configuration files
that you can edit with crontab -e
(to list the contents of the file, use
crontab -l
).
Default cron Jobs
The global crontab
file is contained in
/etc/crontab
.
It includes three cron
jobs by default, which
run the scripts contained in subdirectories of the
/etc/periodic
directory:
/etc/periodic/daily
,
/etc/periodic/weekly
, and
/etc/periodic/monthly
. Each of these directories
contains one or more scripts:
/etc/periodic/daily/100.clean-logs /etc/periodic/daily/500.daily /etc/periodic/monthly/500.monthly /etc/periodic/weekly/500.weekly
By default, /etc/crontab
runs them in the wee
hours of the night:
15 3 * * * root periodic daily 30 4 * * 6 root periodic weekly 30 5 1 * * root periodic monthly
So, if your Mac is not usually turned on at those times, you could
either edit the /etc/crontab
file or remember to
run them periodically using the following syntax:
sudo periodic daily weekly monthly
As you’ll see in Chapter 3, it is vitally important that you run these jobs to ensure that your local NetInfo database is backed up.
You should not modify these files, because they may be replaced by
future system updates. Instead, create a
/etc/daily.local
,
/etc/weekly.local
, or
/etc/monthly.local
file to hold your
site-specific cron
jobs. The
cron
jobs are simply shell scripts that contain
commands to be run as root
. The local ...
Get Mac OS X Panther for Unix Geeks, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.