Use cron to repair permissions on a regular basis

Nov 19, '04 09:51:00AM

Contributed by: Shawn Parr

I don't know why I didn't realize this before, but for those that want to make sure they keep up with repairing permissions, this was made much easier with Panther (10.3). Panther includes a command line version of Disk Utility, called diskutil. If you want to repair your permissions once a week, simply open the Terminal, and do the following:

sudo pico /etc/weekly.local
This uses the pico text editor to create a weekly.local file (feel free to substitute your favorite *nix text editor). This file is looked for by the /etc/weekly script, and run as part of that task if it exists. Then in the file, put something like the following:
# Begin Repair Permissions Script
PATH=/bin:/sbin:/usr/sbin:/usr/bin:/usr/libexec
export PATH
host=`hostname -s`
echo "Repairing Permissions on System Drive"
diskutil repairPermissions disk0s3
# End Repair Permissions Script
If you have changed your partitions and/or disk setup since you first received your machine, type the following in the Terminal to find out what your boot partition is called: diskutil list.

Finally, make the script executable, I suggest the following:
sudo chmod 555 weekly.local
These instructions, plus a better way to do it for OS X Server are available on my blog. If you are someone who turns your machine off at night, this hint, combined with Mac Janitor can take care of both normal cron maintenance and repairing permissions all at once.

Comments (38)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20041117193822290