![]() |
||||||
Running the Mac OS X maintenance scriptsMac® OS X is a UNIX®-based system, built in part on both BSD® and FreeBSD®. UNIX systems run scheduled maintenance routines known as maintenance scripts to clean up a variety of System logs and temporary files. By default, these are executed between 03:15 and 05:30 hours local time, depending on the script. If your Mac is shut down or in sleep mode during these hours, the maintenance scripts will not run. [1] This results in log files that will grow over time, consuming free space on your Mac OS X startup disk. If your Mac is shut down or left in sleep mode overnight, the maintenance scripts should be run manually on a regular basis unless you plan on devoting a large portion of your hard drive to the files cleaned-up by these routines! This FAQ, derived from our book Troubleshooting Mac OS X, provides:
More information about maintaining Mac OS X can be found in our "Maintaining Mac OS X" FAQ. Manually running the maintenance scriptsThe easy wayDownload and install a third-party utility, such as Cocktail or Yasu, that provides a function for running the maintenance scripts. You may find additional solutions by searching MacUpdate or VersionTracker. Employ the version of the utility that is compatible with to the version of Mac OS X you are using. These utilities permit running any individual maintenance script daily, weekly, or monthly or all of them. For example, running all three scripts weekly is a good habit if your Mac is frequently shutdown or in sleep mode overnight. While we have not tested it, we have read positive reports from users of the freeware application Anacron. It runs the maintenance scripts automatically if the computer is awake and the scripts have not run when scheduled. As with other utilities, employ the version of Anacron that is compatible with the version of Mac OS X you are using.. The Terminal wayUsing your Admin account, you can run all three maintenance scripts at once:
All three scripts will run in sequence. There is no visual feedback while the scripts execute. You will know they are completed when the Terminal prompt returns. You can also run the scripts individually. For example, to run just the daily script, you would type the the following command in step 2:
Determining when the maintenance scripts last ranYou can run a Terminal command to quickly check the date and time stamps of the log files associated with each maintenance script. This indicates when the scripts' logs were last updated, hence when the scripts were last executed.
You will see output similar to the following: -rw-r--r-- 1 root wheel 467984 8 May 10:40 /var/log/daily.out -rw-r--r-- 1 root wheel 1258 8 May 10:43 /var/log/monthly.out -rw-r--r-- 1 root wheel 198378 8 May 10:43 /var/log/weekly.out In this example, the scripts last ran on 8 May of the current year, between 10:40 and 10:43 local time. The date and time stamps in the example are the result of running the scripts manually via Terminal. If the scripts were run automatically on their default schedule, their date stamps would vary and their time stamps would indicate executions between 03:15 and 05:30 hours. The maintenance performed by the scriptsEach maintenance script daily, weekly, and monthly has a specific function. Their functions have varied over different versions of Mac OS X.
How the scripts are launched on a scheduleHow the schedule for each script is specified depends on the version of Mac OS X. Scheduling under Panther and JaguarUnder Panther and Jaguar, the schedule is specified in the System crontab file. You can easily view or edit this file with the donationware utility Cronnix. The cron process launches the scripts based on the schedule specified in crontab. Scheduling under later versions of Mac OS XIntroduced in Tiger, the launchd process invokes each script on a schedule specified in a script-specific property list (.plist file) in the /System/Library/LaunchDaemons directory. The specific property list for each script is as follows:
Additional information about launchd can be found in the Apple Developer Connection document System Startup Programming Topics. How the timer used by launchd handles sleep time has led many to incorrectly believe that they no longer need to run the maintenance scripts and that the scripts are run automatically if the Mac was asleep or shutdown at the scheduled time. While it may appear that launchd executes the maintenance scripts "on the fly" if the computer is asleep or shutdown at the appointed time, this is a side effect of how the timer treats the time the computer has spent in sleep mode. The timer used by launchd does not count sleep time. If your Mac is asleep at the scheduled time when a given script is supposed to run, the script may run later that day at a time shifted by the amount of time the Mac was asleep. However, if you restart your Mac before the time-shifted execution time, pending events are lost and the script will not run off-schedule: the next chance for the script to run will be at its regularly scheduled time. If you regularly restart your Mac and the computer regularly sleeps or is shut down at the scheduled times, it's possible that the scripts will never run, hence one should still run them manually, such as on a weekly basis. The sleep time shift is also cumulative. For example, if you don't restart your Mac for weeks or months at a time, but let it sleep when not in use, this can result in:
The time shift in each case is the total amount of time the Mac has spent in sleep since its last restart. If you have a process that writes heavily to the logs, you can end up devoting good hard disk space to the log files. Related linksNotes[1] If you log out from your Mac OS X system and leave it with the Login Window displayed, your Mac can still enter sleep mode. When left at the Login Window, your Mac will enter sleep mode based on the settings specified by the last Admin user in System Preferences > Energy Saver. Therefore, if you want to leave your Mac with the Login Window displayed and still have the nightly Mac OS X maintenance routines run automatically, an Admin user must set System Sleep to Never in the System Preferences > Energy Saver > Sleep tab. |
|
|||||||||||||||||||
|
||||||||||||||||||||