How to Automate Disk Permission Repairs
Automate away the time consuming task of repairing disk permissions on Mac OS X. We create a Power Manager event to call the diskutil repair command once a week to avoid permission problems building up.
Many Mac users like to regularly run the Disk Utility application and repair any misconfigured or incorrectly set file permissions. In this recipe we will create a Power Manager event to repair your Mac’s disk permissions. Our approach though will be fully automated and will not require a user be logged in.
Disk Utility is a graphical application included with Mac OS X. The application is found in the Applications > Utilities folder.
Using the Disk Utility application requires launching and interacting with the application directly. Select the disk to be repaired and then select Repair Disk. The repair process will start immediately but will take a few minutes to complete. Disk Utility needs to potentially check thousand of files on your computer.
A less well known command line edition of the Disk Utility application is also included with Mac OS X:
diskutil. It is this
diskutil command line edition we will use to automate the repair process.
Scripting Repair Permissions
Let’s create an event to repair disk permissions once a week.
Launch Power Manager.
Select the menu item File > New Event… to create a new event.
Select the Run a script daily task and click Continue.
Copy and paste in the following script into Script to run:
#!/bin/sh diskutil repairPermissions /
This script tells
diskutil to repair permissions on the main drive,
5. Set Environment to Super User (root) to provide our script with ample rights to repair any files.
6. Continue through to the When step.
7. Adjust the days and time match your needs; we have asked the repair to happen at 2am every Monday.
8. Continue through the Constraints step.
9. Continue through to the Why step and name your event.
10. Continue and Add your new disk repairing event.
Immediately upon being created, your new disk repairing event is scheduled and ready to use. You can see the scheduled event in the engine view of Power Manager. To switch to the engine view, select the menu item Scheduler > Show Engine.