In order to perform the necessary administrative tasks on your system, Mac OS X makes use of the cron daemon and the periodic utility. The periodic script gets called at three different intervals: Daily at 3:15 AM, Weekly on Saturday at 4:30 AM, and Monthly on the 1st at 5:30 AM. If your machine doesn't run during these times, you can use a utility like Maintain Your Cron to run the scripts at a more convenient time. This hack should still work in conjunction with such a tool.
Sometimes you install crucial utilities that you'd really rather not have consuming your time. Maybe you want Fink to update itself every week. Maybe you have Virex and you want to scan your machine for viruses every day. If the application can be run from the command line (or even if it can be AppleScripted through osascript!), you can create a custom periodic file to execute it auotmatically for you.
At one point when the periodic application runs its various scripts, it attempts to execute a script of the matching name with
.local appended to it. It looks for this file in the
/etc folder. For example, the daily periodic script attempts to run commands in
/etc/daily.local. You can make use of this to run your CLI utilities. Below are two examples of scripts that run common utilities. Remember that to create these files in
/etc, you need the permissions of root, so use sudo or su.
# General parameters
# Update Fink, if present
if [ -f /sw/bin/fink ]; then
/sw/bin/fink selfupdate-cvs && /sw/bin/fink update-all
# General parameters
# Check disk permissions
/usr/sbin/disktool repairPermissions /
# Virus scan with Virex
echo "Scannning for viruses..."
./vscanx -rc --summary --ignore-links --one-file-system / >/dev/null
These are great examples to get you started. By default, the output of your periodic scripts are put in a file in
/var/log that is named after the script and then appended with
/var/log/daily.out). If you'd instead like to have these logs emailed to you, add a line that says "MAILTOfirstname.lastname@example.org" to the top of your
/etc/crontab file. Then, create a file called
/etc/periodic.conf.local that contains the following:
# Output options
Keep on hacking!
man periodic, man cron