How to Automate Disk Permission Repairs

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.

Screenshot showing Disk Utility on Mac OS X

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.

  1. Launch Power Manager.
  2. Select the menu item File > New Event… to create a new event. Select Add in Power Manager to create a new event
  3. Select the Run a script daily task and click Continue. Select the Schedule Assistant task Run a script daily
  4. 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. Paste in the disk repair script
  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. Adjust the trigger time of day and days
  8. Continue through the Constraints step. Continue through the Constraints step
  9. Continue through to the Why step and name your event. Name and describe your event in the Why step
  10. Continue and Add your new disk repairing event. Confirm the event The disk repairing event has been created

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.

The disk repairing event is created and reayd

This article was posted in , , and and tagged , , and .

Published by Graham Miln on