Use anacron to run periodic jobs (Panther only)

Mac OS X Add comments

Mac OS X, like any unix, has certain system maintenance jobs that run daily, weekly, and monthly. Those jobs are usually set to run in the wee hours of the morning when computer usage is likely to be at its least. This turns out to be a problem for notebook users because, unlike a desktop, notebooks are more likely to be powered off or asleep at the time those system maintenance jobs would usually run. Cron isn’t very smart, so if a job is supposed to run at 3:00 AM, and 3:00 AM passes while the computer is asleep, the job is never run. Cron doesn’t check back to see what it missed, it only knows what it’s supposed to run right now, so on many notebooks these basic system maintenance jobs are almost never run.

Every once in a while, a Mac OS hints and/or tips site posts someone’s latest brainstorm about how to deal with this quirk. I don’t question the validity of these methods since I’ve never tried them, but I know there’s a very simple way to deal with cron jobs that are missed.

There is a free unix utility called anacron that is available for download here. Missed cron jobs have existed in unix for a long time, and a solution was provided long ago.

The anacron download I linked to comes as a Mac OS X installer package, so it’s a normal double-click install, no unix knowledge necessary. It comments out the usual daily, weekly, and monthly jobs in the crontab and instead inserts a line that instructs anacron to run every 15 minutes. At each 15 minute mark, the anarcon executable runs and determines whether any jobs, specified in /etc/anacrontab, need to be run or have been missed. Despite running fairly frequently, anacron has almost zero overhead and will have no impact upon system performance.

When a notebook has been asleep overnight, anacron will make sure periodic jobs are run. Failure to run system maintenance tasks may degrade your Mac’s performance over time, so make the minimal effort to install anacron.

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in