Wednesday, June 13, 2007

Mac系统日常维护

Delete Cache Files

Why: Cache files are temporary receptacles for data that help OS X and its applications work faster. They can become corrupted or simply too large to function well. If you're experiencing odd issues with an application—such as preferences that won't load or menus that contain strange characters—or if an application or the system seems sluggish, it may be a cache-related issue.

When: Removing cache files once or twice a month works well for most people, but if your Mac is always on and working, you may want to remove cache files once a week to prevent corruption.

Who: Everyone.

A cache is a place to store something temporarily so the OS or a program can retrieve and use it in a hurry. G4 and G5 processors have caches that help them handle instructions more quickly. OS X uses disk-based caches that hold copies of graphics, frequently performed calculations, and the contents of dynamic menus. Caches help reduce application launch times, speed up the display of screen data, and make Web sites load faster.

You'll find OS X's cache files in the System: Library: Caches folder, in your user folder's Library folder, and in folders within individual applica-tion folders. The easiest way to remove most of them is to use one of the tools listed in the "Managing Mac Maintenance" chart. (Except for Safari's caches, these tools generally don't affect application-specific caches; you'll have to wrangle these files yourself.)


Regularly deleting your cache files is a good idea. And if you're seeing slowdowns or other unexplained behaviors, there's no harm in trying to rout the bad behavior by deleting the cache files.

Delete Log Files

Why: Log files record system- and application-related activity. They grow over time, using disk space to store data you'll never need.

When: Log files don't normally grow excessively large, so you can delete them only when you want to reclaim drive space.

Who: Users concerned with freeing every bit of available drive space, and users who make extensive use of FTP, Web, and other bundled Unix applications.

As you work, your OS and applications automatically create log files that record everything from the mundane to the important. Large log files don't cause system instability, but when diminishing disk space becomes a concern, there are a couple of ways to clean up.

Like cache files, log files are stored in several places, from the system level (in the /var/log and /Library/Logs folders) to your user folder (~/Library/Logs). You can run OS X's built-in daily, weekly, and monthly maintenance scripts to take care of the system-level log files. To root out log files at the user level, you need either the Console application (in Applications: Utilities) or an application such as NoName Scriptware's CacheOutX.

In Console, delete any log listed in your user folder's Library: Logs folder by highlighting it from the left-hand Logs column and pressing Command-delete. After you confirm your action, that log file vanishes. Your Mac automatically re-creates it the next time the system or the program needs to write something to the log.


Automate Your Maintenance

Why: OS X comes with a set of Unix scripts that run automatically. They delete and archive unnecessary data created through normal use of your machine.

When: You don't have to lift a finger—the scripts run daily, weekly, and monthly, as long as your machine is awake at their scheduled run times.

Who: Heavy users of the command line.

OS X is designed to make basic maintenance tasks invisible to you. The operating system regularly cleans up the little files that can clog your machine—from system logs to FTP logs to firewall logs. But there's a catch. OS X's cleanup scripts are set to run at specific times. The daily script runs at 3:15 a.m., the weekly script runs at 4:30 a.m. on Saturdays, and the monthly script runs at 5:30 a.m. on the first day of the month. Apple probably chose these times because you're not likely to be using your machine during the wee hours, so you probably won't be bothered by the CPU draw or the drive noise. Unfortunately, those times are also when most of our machines are powered off or sleeping, so the scripts can't execute.

Most people won't see problems if these scripts don't run regularly, but a few will. To find out if you're vulnerable, take a closer look at each script.

The daily script cleans up the tmp directory, where many programs and installers store files that aren't permanently required. iChat, for instance, keeps copies of images you've sent in the tmp folder. (Your machine empties this folder when you restart.)

However, the daily script also backs up your NetInfo database, an essential file with information on your users, services, and devices. If you don't regularly back up this file in some other way, I suggest running the daily script. (Note that recovering this file from a backup is very complicated. Go to this article for a how-to that's not for the faint of heart.)

The daily script also creates a network-interface status report and a free-disk-space report, and rotates the system.log files by creating multiple compressed backup copies.

The weekly script updates the locate and whatis databases (two files that are very useful when you spend a lot of time in Terminal); archives older secondary system logs, such as FTP; and archives Web-server logs. It also restarts your Web server.

The monthly script runs a user time-accounting script (not much to it when you're the only user on your machine) and rotates installer log files.

You can look for reported errors in the output of these scripts by opening the Console program (Applications: Utilities), clicking on the /var/log line in the Logs column (click on the Logs button in the toolbar if you can't see this column), and then selecting daily.out, weekly.out, or monthly.out. The contents of the file display to the right.

If you've decided that running the scripts is important, but you don't want to keep your Mac on and awake at the times they run, see "Run, Scripts, Run!" for tips on changing the automatic run times.

Keep Hard Drives Healthy

Why: An unhealthy hard drive is a nightmare. SMART (Self-Monitoring Analysis and Reporting Technology) lets you perform a routine checkup that identifies potential drive failures before they happen, so you have time to update backups and look for replacement drives.

When: You (or an automated application) should check SMART indicators daily.

Who: Everyone.

The hard drive or drives inside your Mac are critically important—if the hard drive fails, the Mac won't boot, and you could lose all your files. While there's nothing you can do to physically maintain your drives, there are some tools that sniff out disk weaknesses, and there are a couple of ways to recover data when you do have trouble.

SMART Status Indicators The SMART hard drives in newer Macs diagnose their own health, and they note any problems they find with internal drives on an IDE/ATA or SATAbus.

There are two ways to check the status of your Mac's SMART indicators. If you're using the machine locally, launch Disk Utility (Applications: Utilities) and click on the top-level indicator for your drive in the left-hand column. In the bottom of the window, you'll see the words SMART status, and next to that, you'll see the word verified. If you don't see SMART status, your Mac doesn't have the technology. If you see the phrase but it's not accompanied by verified, you should back up your hard drive and then replace it—it will likely experience a failure soon.

If you prefer to use Terminal, or if you connect remotely to Macs—for instance, if you have a Mac in your home that you're using as a server—you can also check the status of the drives from Terminal. In Terminal, type diskutil info disk0 | grep SMART , assuming that the Mac has only one hard drive. If the Mac has more than one hard drive, type diskutil list to see which drive numbers are assigned to each drive, and then repeat the first command with the proper number.

Manually checking SMART indicators gets old fast. If you're comfortable in the command line, you can add a new cron task that executes this command on a regular basis and writes the output to a text file; you can also create an AppleScript that displays a dialog box and then set the AppleScript to run at login each day. Or you could let a third-party application, such as Alsoft's $80 DiskWarrior (see Best Current Price ), Micromat's $98 TechTool Pro 4, or Julian Mayer's free SMARTReporter, inspect the drives and alert you if there's an error.

Advanced Maintenance and Repair SMART indicators don't catch everything. Despite your best efforts, you might power up your machine one day and see the dreaded blinking question mark.

Your first step should be to boot from the OS X Install CDs. Next, select Open Disk Utility from the Installer menu (next to the Apple menu). If your boot drive shows up in the left-side drive list, select it, and click on Repair Disk—then sit back and cross your fingers. Disk Utility may be able to repair the disk; if it does, restart and hope the drive works as usual. Then back up important files and consider investing in a new drive.

If Disk Utility can't repair the drive, it's time for DiskWarrior or TechTool Pro 4. DiskWarrior is primarily a directory-repair tool. Its directory-rebuilding feature has returned seemingly dead drives to the land of the living. TechTool Pro also recovers data from dead drives, through a different mechanism. In addition, it can monitor and test a number of other aspects of your system, such as CPU, memory, and power supply. Both are capable tools; which to use is really a matter of per-sonal preference.

If you can't make the drive work with either of these programs, it has probably suffered a physical failure of some sort. If you're willing to dole out serious dough, companies like DriveSavers Data Recovery can often recover data from even badly damaged drives.

Construct a Maintenance Toolbox

Why: Maintaining your Mac doesn't have to be a burden. There's software that can handle it with ease, and some programs even throw in additional system-tweaking features.

When: There's no sense in waiting to download helper applications.

Who: See the "Managing Mac Maintenance" chart for an easy-to-scan list of the applications and their abilities. Out of that list, every Mac user should have at least three: OnyX, SMARTReporter, and DiskWarrior.

OnyX For general system maintenance, Titanium Software's OnyX is tough to beat. It's free, it has a clean interface, and its help system is easy to understand. OnyX's features go well beyond basic maintenance: the program lets you erase caches, logs, browser cookies, and even Safari's cached bookmark icons with a few mouse clicks. Throw in the ability to run a Terminal command, browse log files, and view Unix manual (man) pages, and you've got a maintenance winner.

SMARTReporter Julian Mayer's SMARTReporter checks SMART status indicators. While many programs can do this (including Apple's Disk Utility), I prefer SMARTReporter's reporting capabilities. With its intuitive interface, you'll have your drives set up for regular monitoring in no time. You specify the testing interval and the actions to take if a test fails. You can even control SMARTReporter's appearance in your menu bar—a solid green or red disk icon, or just a small green or red dot that indicates the status of the most recent test.

DiskWarrior When your hard drive appears to be dead, you need a drive-repair utility. And DiskWarrior's ability to resuscitate drives is unmatched. Using a proprietary and patented technique, DiskWarrior builds a new directory for your drive. Once this new directory is built, DiskWarrior lets you mount it as a new hard drive, so you can check it for errors and even copy files off of it. If everything looks good, DiskWarrior then writes its new directory onto your drive. DiskWarrior can't save you from hardware failures that render the drive unusable, but for nearly everything else, it's an invaluable data-saving tool.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home