Maintenance Magic

Keeping your drive(s) healthy is an obvious form of Mac maintenance. However, OS X presents several other "opportunities" for maintenance that many Mac users have never encountered before. (How'd you like that use of euphemism?) Here are three you should know about.

Periodic Permissions Patching

User Level:

admin

Affects:

computer

Terminal:

no

I talked about repairing permissions and privileges in Chapter 1 as a way to fix permissions-related problems. In Chapter 4, I also recommended repairing permissions before and after installing major system updates. However, in my experience, permissions get screwed up on their own fairly regularly. Most of the time the consequences are extremely minor; however, I find it useful to run Disk Utility's Repair Disk Permissions function on my startup drive on a regular basis. (I tend to run it once a week.) I can't guarantee any results, but I can tell you that I've seen fewer permissions-related problems, and fewer problems in general, since I've made this one of my regular routines.

Tip 

I showed you how to run Repair Disk Permissions in Chapter 1, but if you're interested, I'll show you how to make it run automatically in the background later in this chapter under "Automating Admin Actions."

Running Routines (Unix Routines, That Is)

User Level:

admin

Affects:

computer

Terminal:

possibly

Because OS X is based on Unix, it still exhibits a few remnants of classic Unix behavior. One of these is its reliance on "cleanup" scripts. Unix operating systems maintain a number of activity logs (discussed later in the chapter), databases, and temporary files that need to be cleaned out and/or updated periodically. To take care of these tasks, Unix computers (including yours, running OS X) use three scripts, called daily, weekly, and monthly, to perform these actions. These scripts remove unnecessary temporary files, archive or delete old log files, and update databases (such as the locate database I talked about in Chapter 5). They run, as you might guess, daily, weekly, and monthly, respectively.

Unfortunately, on many Macs these scripts never get run. Because Unix computers have historically been used as servers or number-crunching workstations, system administrators didn't want to run these scripts—which can take a good deal of time and system resources—during the day when users were most likely to be using the computer. So, since most Unix computers were left running 24/7, they took advantage of Unix's cron automation utility to schedule the execution of these scripts at times when computers would least likely be in use. (I'll talk more about cron later in the chapter.) Over time, these execution times became standardized across entire distributions of Unix; in OS X, the daily script is scheduled to run every morning at 3:15 A.M., the weekly script is scheduled for 4:30 A.M. Saturday mornings, and the monthly script will be run at 5:30 A.M.on the first day of each month.

The problem is that most Mac users don't leave their computers on all night—if your computer isn't running (and awake), the scripts don't get run, so your temp files don't get deleted, your log files grow larger, and your databases aren't updated. Although this isn't a disaster, your log and temp files can grow very large over time, and if you actually use any of the databases in question (such as the locate database), they won't be updated versions. If your computer is shut down or asleep at night, here's how to get these scripts to run.

Tip 

If you do leave your computer on at night, you may as well skip to the next section right now, because you're set.

There are actually a few simple solutions to this predicament. The first is that you can occasionally leave your Mac running at night so that the scripts will run. For example, if you leave your Mac on every Friday night/Saturday morning, and the last day/first morning of every month, your monthly and weekly scripts will run as scheduled, and the daily script will at least be run once per week, which is sufficient for most users.

The second approach is to use utility like the freeware MacJanitor (http://personalpages.tds.net/~brian_hill/macjanitor.html) or the shareware Xupport (mentioned earlier in the chapter) to run any or all of the scripts at your leisure. When you launch MacJanitor and provide your admin password, you can execute any of the scripts by clicking on its button in the toolbar, or click the All Tasks button to run all three (Figure 14.3). The bottom of the window displays the scripts log output so you can see what is happening. Xupport's Optimize panel offers similar options.

click to expand
Figure 14.3: MacJanitor lets you manually execute OS X's periodic maintenance scripts.

Tip 

If you're feeling adventurous, you can do the same thing as MacJanitor and Xupport using Terminal. Simply type sudo periodic script <RETURN>, where script is daily, weekly,or monthly. After providing your admin password, the script will run, and you can feel good knowing that you used a Unix command line to run the script just like they did in the old days.

The only downside to using a tool like MacJanitor or Xupport (or Terminal) is that you have to remember to use them. If automating the process is worth a few bucks to you, check out the shareware Macaroni (http://www.atomicbird.com/). Macaroni runs as a preference pane and provides two helpful features. First, each time you start up, Macaroni checks each script's schedule, and then checks to see if the script was actually run on schedule. If a script didn't run when it was supposed to, Macaroni runs it. This way your maintenance scripts never get behind schedule. The second feature is that you can actually change the schedule (by day) on which the scripts are run. For example, you can choose to have the daily script run every other day instead of daily. Or you can change the day of the week or month on which the weekly or monthly script (respectively) should be run.

Tip 

As a bonus, Macaroni can even schedule other shell scripts to be run at certain intervals and can run OS X's Repair Permissions feature on the schedule you choose.

If you're curious as to exactly what the daily, weekly, and monthly scripts actually do, they're located at /etc/periodic/daily/500.daily, /etc/periodic/weekly/500.weekly, and /etc/periodic/monthly/500.monthly. You'll probably find the code to be little more than gobbledygook unless you're a Unix pro, but the comments (preceded by #) are often fairly descriptive. You can also download MacJanitor (mentioned above); it comes with a text file called "What Is It Doing?" that includes a brief summary of each script in plain English. Finally, each script produces its own log file (daily.out, weekly.out, and monthly.out), stored in /var/log.

Tip 

If you have your own shell scripts that you'd like run daily, weekly, or monthly, you can actually place them in /etc/periodic/daily, /etc/periodic/weekly, or /etc/periodic/monthly, respectively. They'll be run immediately after the standard cleanup scripts— the last action of each script is to check the enclosing folder for other scripts to run. (I'll talk more about shell scripts in the next chapter.)

Cache Cleaning

User Level:

any or admin

Affects:

individual user or computer

Terminal:

no

Remember back in Chapter 2 when I told you that many problems with the System Preferences application (a freeze at launch, multiple instances of the same preference pane, etc.) can be fixed by throwing away its cache file? This issue of corrupt cache files isn't isolated to System Preferences. The truth is that cache files are used quite frequently in OS X as a way to store frequently accessed data and, as a result, can impact a lot of things.

For example, one of the most common cache-related issues under OS X 10.2 is a situation where you can no longer drag files or folders in the Finder. No matter how hard you try, they appear to be permanently glued in place. One solution is to delete certain cache files from your ~/Library/Caches directory. A number of other problems in Jaguar can similarly be solved by discarding files in that folder, or in several other local- and system-level cache folders (e.g., /Library/Caches, /System/Library/Caches, and /System /Library/Extensions.kextcache).

In addition to occasionally contributing to problems, some cache files grow larger and larger over time, taking up more and more disk space. (I recently checked my Caches directory and found that it was over 200MB in size.) If you're a neat freak, you may enjoy throwing out unnecessary cache files that are just cluttering your hard drive.

Although you could clear out many of these files manually, there are two utilities that do an excellent job of automating the process: the donationware Dragster (http://ifthensoft.com/) and the shareware Jaguar Cache Cleaner (http://www.northernsoftworks.com/jaguarcachecleaner.html). Dragster is specifically designed to fix the bug described above where you can't drag items in the Finder. It deletes a specific list of cache files (and a few preferences files, such as the Finder preferences) that have been directly linked to the glitch. I've personally experienced the "no drag" problem twice, and both times Dragster solved the problem. In addition, at your request it can also delete several other Finder- and Dock-related files that can contribute to Finder problems, such as all the invisible .DS_store files that exist in every folder on your hard drive. (These files contain your individual window preferences; when one or more is corrupt, you can experience odd window behavior.)

Jaguar Cache Cleaner (JCC), on the other hand, attempts to fix the aforementioned Finder bug, but it also deletes many other files that may be related to a broader range of system issues. However, because it deletes more files, some of which may include important information, JCC's developer recommends that you first try other troubleshooting options, such as running Disk First Aid to repair your disk and permissions. If you decide to use JCC, you can choose the Light Cleaning option first; if that doesn't work, a Deep Cleaning option deletes a more extensive list of files. You can also choose to have JCC clean (read: delete) files in just your user cache directory, the local cache, the System cache, and/or other users' cache directories.

Note 

Both Dragster and Jaguar Cache Cleaner require a restart after doing their job, so be sure to save any documents before running either utility. In addition, both also require an admin password if you want them to remove any system- or local-level files.

In addition to its "cleaning" functionality, Jaguar Cache Cleaner also has a few other features. Although they're unrelated, having them in easy reach can be convenient. For example, JCC lets you enable and disable journaling on any mounted volume (see the sidebar on journaling earlier in the chapter for details). JCC will also allow you to manually run OS X's three maintenance scripts, as discussed in the previous section, and run the Repair Disk Permissions routines without having to open Disk Utility. (I show you how to automate this in the next section.) Finally, JCC has two features that I don't really recommend using: first, you can manually delete virtual memory swap files—I don't like this feature because you generally shouldn't be deleting swap files; a simple restart will remove them all for you without the possibility of adversely affecting OS X's virtual memory system. Second, JCC lets you drop into single-user mode from the Finder. I don't recommend this because you still have to restart after using single-user mode via JCC, so you may as well just restart and access single-user mode normally.

Tip 

I tend to manually empty the three /Caches directories every few weeks, and turn to Dragster or JCC only when I experience strange Finder or application behavior that I can't fix by throwing away preference files.

If you're still running OS X 10.1.x, some of the problems described above can be attributed to a few other files in addition to cache files. These files are located in ~/Library/Preferences, and all begin with .LS. Both utilities described above will also remove these files for you.




Mac OS X Power Tools
Mac OS X Power Tools
ISBN: 0782141927
EAN: 2147483647
Year: 2005
Pages: 152
Authors: Dan Frakes

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net