What do the periodic scripts do?

2007-10-15 23:29:17 -08:00

Mac OS X includes three scripts that run at different periodic intervals. There are a number of utilities—such as Macaroni (currently on sale through Friday), Cocktail, MacJanitor, and Anacron—that will run these scripts at your command or move them to a more convenient schedule (since we don’t all leave our Macs running all night). (UPDATE 2007-10-16 07:31: Not that that’s necessary. Tiger will run the periodic scripts at next opportunity, if the regularly scheduled time is missed. See Augie Fackler’s comment below.)

The problem is that these scripts have become voodoo, like zapping the PRAM or rebuilding the Desktop file or repairing permissions. People run them for no reason and any reason. Something wrong? Make sure you’ve run the periodic scripts!

The truth is: The periodic scripts won’t fix anything. At best, they’ll save you a very tiny bit of disk space.

Here, in plain English, is the full list of everything the periodic scripts do as of Mac OS X 10.4.10.

There are three scripts: “daily” runs at 0315 every morning, “weekly” runs at 0315 every Saturday, and “monthly” runs at 0530 on the first day of every month.

Daily

  • Clean out crash logs older than 60 days.
  • Delete temporary files used by the rwho command older than 7 days. If you don’t use rwho, this doesn’t affect you. (It doesn’t even seem to be enabled on my system. It may only be in use on Mac OS X Server.)
  • Cleans out the /tmp (temporary files) directory
  • Cleans out old temporary files for faxes.
  • Removes system messages older than 21 days. I don’t know of anything that actually sends a system message by the mechanism involved.
  • Sweeps up old system accounting statistics. These are solely for monitoring by a human administrator; they aren’t needed by the system. This feature may not even exist on Mac OS X, or may be only on Mac OS X Server; the folder that this cleans out doesn’t even exist on my system.
  • Makes a backup copy of the NetInfo database, which contains information such as Mac OS X account details. Unless you frequently add and remove such accounts, you probably don’t need to worry about making sure this runs.
  • Lists several things in the output:
    • Disks, with amounts of space used and free (df -k -l)
    • Recent backups made with the dump command
    • The mail queue (is your Mac a mail server? probably not, in which case this doesn’t do anything)
    • Network interfaces (Ethernet ports, AirPort cards, IP over FireWire), with their IP addresses and counts of packets sent and received
    • Uptime for all systems on the network, if rwho is active (it isn’t, on my system)
  • Rotates system.log. The script deletes system.log.9.gz, renames system.log.8.gz to system.log.9.gz, renames system.log.7.gz to system.log.8.gz, and so on. It then compresses the current system.log, renaming it to system.log.0.gz in the same step, and starts a new system.log.

Weekly

  • Updates the locate database. locate is just a find-files command.
  • Updates the whatis database. whatis is just a command that briefly describes other commands. For example, “whatis locate” describes locate as “find files”.
  • Rotates the log files of the FTP server, DNS, print server, mail server, NetInfo server, Xserve hardware-monitoring server, firewall, PPP (dial-up internet—remember that?) system, and security server. (The security server is responsible for authorization dialogs, the Keychain, and the sudo command.) Of these, most Macs have only DNS, NetInfo, and the security server actually in use; the others are not even running.
  • Rotates the log files of the web server. If you don’t have “Personal Web Sharing” (also known as Apache) turned on, this doesn’t affect you.

Monthly

  • Reports in the output how much time each user on the system has spent in a terminal in the past month (as a running count of days spent—it’s not broken down by weekdays or anything like that).
  • Rotates the file used by ac to tally up how much time each user is spending in a terminal (see previous list item).
  • Rotates the Installer log. I think this also covers Software Updates, but I’m not sure. It doesn’t cover third-party application updates.
  • Rotates the fax logs.

While all of that is nice to do once in awhile, you don’t need to do it and it won’t fix anything. UPDATE 2007-10-16 07:31: Further, as Augie points out in his comment, Tiger will run the periodic scripts at the next opportunity anyway, so there is NO reason to run them yourself.

One Response to “What do the periodic scripts do?”

  1. Augie Fackler Says:

    From man 5 launchd.plist:

         StartCalendarInterval 
         This optional key causes the job to be started every calendar interval as
         specified. Missing arguments are considered to be wildcard. The semantics
         are much like crontab(5).  Unlike cron which skips job invocations when
         the computer is asleep, launchd will start the job the next time the com-
         puter wakes up.  If multiple intervals transpire before the computer is
         woken, those events will be coalesced into one event upon wake from
         sleep.

    So it’s redundant to ever manually run the periodic scripts – they already fix themselves. Of course, this only holds true on 10.4 and later. So, moral of the story: never run the periodic scripts manually in 10.4 and later. They can take care of themselves.

Leave a Reply

Do not delete the second sentence.


Warning: Undefined array key "ntt_saved_comment_text" in /home/public/blog/wp-content/plugins/negative-turing-test/negative-turing-test.php on line 143