Running Repair Permissions Automatically
Repairing permissions in Leopard or Tiger is an important part of keeping a your Mac running smoothly. Doing this on a regular basis will help avoid problems and improve the stability of your Mac. The procedure below will work for Tiger as well as Leopard.
What Repair Permissions Does: Repair Permissions is part of the Disk Utility application that is installed on every Mac and is in the Applications/Utilities folder. Leopard has an internal database that it uses to keep track of the proper permissions for the System files and folders. When you install or uninstall a program, the System permissions might be left in a state that is not correct. It might not cause problems immediately, but later on applications might have trouble saving preferences or updating or just have instability issues.
Now you can startup Disk Utility and select your main system disk and click on the button to run Repair Permissions but you have to remember to do that on a periodic basis. It’s a good idea to run it after you have installed or uninstalled a lot of applications. It also a good idea to run it before and after a Mac OS X Update (i.e. updating from 10.5.5 to 10.5.6)
Built-in Periodic Tasks:
Leopard already runs periodic tasks, daily, weekly, and monthly. The are normally run in the middle of the night, if you leave your Mac running overnight. If you turn off your Mac at night, the tasks still get run, they are just run the first few minutes after you turn your Mac back on.
We are going to take advantage of this built-in feature to run Repair Permissions on a weekly basis. If you don’t install or uninstall applications on a regular basis, you could easily change the procedure below to run Repair Permissions on a monthly basis instead.
We are going to create a one line script that will run Disk Utility and Repair Permissions, The script will also have a special name that will allow Leopard to recognize it automatically. Leopard runs multiple tasks on a daily, weekly, and monthly basis and has these scripts predefined. We DON”T want to change these scripts to include our command line because the predefined script might be over written by a Mac OS X update in the furture and our modifications would be lost.
The Local Boys:
Apple has enabled a way to allow custom tasks to be done right after the predefined tasks are completed. This allows you to create any script and run the commands in that script on a daily, weekly, and monthly basis, just by naming the script appropriately and putting it in the correct folder. To enable the script to run on a daily basis, just make sure the name is daily.local, on a weekly basis, weekly.local and on a monthly basis, monthly.local. The .local extension tells Leopard that this is a custom file for this installation of Leopard.
The file needs to be placed in the /etc directory of the system disk and set with the appropriate permissions to execute.
The Gory or Geeky Details:
This is going to require the use of the Terminal application, so be warned, if you’ve never used Terminal before it’s probably not a good idea to do this yourself.
- To do this procedure you need to have administration rights on your Mac.
- Open the Terminal application in the Utilities folder.
- Enter the following commands:
- sudo pico /etc/weekly.local
- enter your login password to allow you to create this file
- In the pico editor enter the following single line of text.
diskutil repairpermissions /
- Press control-x and then the y key to save the file
- You should now be out of the pico editor and back to your command line prompt. Enter this command.
- sudo chmod 755 /etc/weekly.local
- You might have to enter your password again. This command sets the execute permissions for the script.
- Note: Name the script file monthly.local if you want Repair Permissions done monthly.
- Quit the Terminal program
- You are done!
Now Repair Permissions will run on a weekly (or monthly) basis. The output of the script will be saved in the weekly.log or monthly.log file. You can see this log file by running the Console application in the Utility folder. To see the log file make sure you can see the log list by clicking on Show Log List, and then open the LOG FILES list. In this list open the /var/log section. Scroll down and click on weekly.log or monthly.log depending on what you setup. You should be able to see the output of the Repair Permissions command. You will have to wait a week or a month to see the output depending on the date the last tasks were run.
Leave a comment if you find this helpful or have any questions.