----------------------------------------------- Automating OS X System Maintenance with Anacron The default install of OS X schedules the cron jobs specified in /etc/{daily,weekly,monthly} to run at 3am, 4am, and 5am respectively. This schedule is good in the sense that the tasks will run at a time when the computer is unlikely to be in use. However, if the computer is a laptop or office computer that is shut off at the end of the day, these tasks (including rotating the logfiles, cleaning out /tmp, etc.) will _never_ be run. One solution to this problem is to put these system cron jobs under anacron's control. Doing this has both an upside and a downside: Upside: The tasks _will_ be run once a day/week/month. Downside: The precise time of day when this will happen is not guaranteed. If you want to do this, you must make three changes to the crontabs: 1) Edit /sw/etc/anacrontab and uncomment the lines for cron.daily, cron.weekly, and cron.monthly: ##period delay job-identifier command 1 5 cron.daily sh /etc/daily 2>&1 | tee /var/log/daily.out | mail -s "`hostname` daily output" root 7 10 cron.weekly sh /etc/weekly 2>&1 | tee /var/log/weekly.out | mail -s "`hostname` weekly output" root 30 15 cron.monthly sh /etc/monthly 2>&1 | tee /var/log/monthly.out | mail -s "`hostname` monthly output" root 2) Comment out the corresponding cron.daily, cron.weekly, cron.monthly lines in /etc/crontab: # do daily/weekly/monthly maintenance #15 3 * * * root sh /etc/daily 2>&1 | tee /var/log/daily.out | mail -s "`hostname` daily output" root #30 4 * * 6 root sh /etc/weekly 2>&1 | tee /var/log/weekly.out | mail -s "`hostname` weekly output" root #30 5 1 * * root sh /etc/monthly 2>&1 | tee /var/log/monthly.out | mail -s "`hostname` monthly output" root 3) Add a line to /etc/crontab to run anacron at whatever schedule you would prefer. (Keep in mind that running anacron doesn't necessarily do anything; it merely checks to see if anything listed in /sw/etc/anacrontab is due to be run. If not, it just exits. As an example, if you wanted it to run once a day at 8.30 in the morning you would add the line: #min hour mday month wday user command 30 8 * * * root @PREFIX/sbin/anacron -s For more on the various permutations of this, consult the crontab.5 manpage. One other thing to note is that anacron is run by default at boot-time, so if the computer isn't on at the time you set in the line above, it'll still be guaranteed to run the next time you turn on the computer.