Maintenance Scripts

From Mac Guides

Jump to: navigation, search

Mac OS X runs maintenance scripts at 0300 (3:00am), which performs tasks such as clearing log files. However, if your computer is off or in sleep mode at this time (which is typical of laptops), the scripts will not run.

In Tiger, Apple changed the way these Maintenance Scripts are run. They are now controlled by Lanuchd. Since 10.4.2, if the computer is in sleep mode or off, Lanuchd will run these scripts at its earliest connivence. No additional work or software required. Prior to Tiger, the Maintenance Scripts were controlled through cron, a UNIX scheduling daemon.

You can use third party applications such as Cocktail or MacJanitor to run these scripts.

Alternatively, you can run them yourself using the Terminal. To do this, follow these steps:

  1. Open the Terminal application, located at /Applications/Utilities/Terminal
  2. Type in the Terminal window (without quotes):
    sudo periodic daily weekly monthly
    and then press the return key to run all the scripts
  3. Enter your administrator password. The characters will not show, nor will any placeholder character appear either. This is done for security reasons, and the computer really is taking input. Press the return key when you are done entering your administrator password.
  4. Running the scripts may take a while. You will not be given progress updates, however you will know they are finished when a prompt reappears.

An example Terminal screen, with the username removed, is shown below.

Image:Force_Run_Maintenence_Scripts.png


To determine when the maintenance scripts last ran, follow these steps:

  1. Open the Terminal application, located at /Applications/Utilities/Terminal
  2. Type in the Terminal window (without quotes):
    ls -al /var/log/*.out
    and then press the return key.

The output will show similar the following, the daily script last ran at 3.15am, 10 November this year.

-rw-r--r-- 1 root wheel 467984 10 Nov 03:15 /var/log/daily.out 
-rw-r--r-- 1 root wheel 1258 1 Nov 05:30 /var/log/monthly.out
-rw-r--r-- 1 root wheel 198378 8 Nov 03:15 /var/log/weekly.out