Run the OS X maintenance scripts


Issue: Like other Unix-based operating systems, Mac OS X runs scheduled maintenance routines to clean up a variety of system logs and temporary files. By default, these are executed between 03:15 and 05:30 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. This results in log files that will grow over time, consuming free space on your OS X startup disk. If your Mac is shut down or left in sleep mode overnight, you should invoke these maintenance routines manually on a regular basis.


Solution:

Manually running the maintenance scripts – Using an administrator-level account, you can execute all three maintenance scripts at once by issuing the following command in a Terminal or xterm (X11) window:

sudo periodic daily weekly monthly

All three scripts will run in sequence. There is no visual feedback while the scripts execute.

Determining when the maintenance scripts last ran – You can check the date and time stamps of the log files associated with each maintenance script, which indicates when the scripts were last executed. Use the command

ls -al /var/log/*.out

The maintenance performed by the scripts – Each maintenance script has a specific function.
  • The daily script removes old log files, “scratch” and “junk” files, backs up the NetInfo database, reports a variety of system and network statistics, and rotates the system.log file. Under Tiger, the daily script also cleans up scratch fax files and prunes asl.log, the log for the Apple System Logging facility.
  • The weekly script rebuilds the locate and whatis databases, and rotates the following log files: ftp.log, lookupd.log, lpr.log, mail.log, netinfo.log, ipfw.log, ppp.log, and secure.log.
  • The monthly script reports per-user usage accounting and rotates the wtmp, install.log, and cu.modem.log files.
OS Version Compatibility: Lion, Snow Leopard, Leopard, Tiger

Update Status: 03 December 2009