Ads by TechWords

See your link here
Receive the latest technology news and information.
Computerworld Daily News (First Look and Wrap-Up)
Computerworld Blogs Newsletter
The Weekly Top 10
Cloud Computing
View all newsletters




Privacy Policy
 

Looking at the changes to Snow Leopard's top command

November 12, 2009 02:09 PM ET

Macworld - I often use top in Terminal as a quick-and-dirty version of Activity Monitor. top can report on CPU and memory usage, and much more. Because I have Terminal running all the time, top is only a few keystrokes away when I'm curious about what my system may be up to.

In OS X 10.5, I used top -u 10 regularly; the -u flag sorts by CPU usage, and the 10 restricts the output to 10 processes. This gave me a quick snapshot of the top CPU usage hogs on my Mac. I used this command so often in 10.5 that I had set it as an alias; I just needed to type t10 to run it.

In 10.6, though, this command fails, and fails miserably, because top has been updated to a much newer version (the 10.5 version of top is dated September 25, 2008; the 10.6 version is dated June 25, 2009.)

In the new version of top, many of the runtime options have changed, including -u (which is now used to specify a username). You can find out more about the new version by typing man top in Terminal.

In case you'd just like the easy way to recreate my simple CPU usage tracker from 10.5, the 10.6 version of the command is:

top -o CPU -n 10

Now that I have the above command assigned to my t10 alias, everything works as it did in 10.5.

In addition to the changed runtime options, Mac OS X Hints contributor felix-fi points out a useful new feature in the 10.6 version of top: it's now dynamic.

In 10.5, if you started top and resized the Terminal window, nothing would happen--top would just continue to display the same columns as it did when you launched it.

In 10.6, though, top will show additional data as you expand the Terminal window--make it wide enough, and eventually you'll see 26 separate columns of data.

On my 15-inch MacBook Pro, seeing all the columns requires reducing the font size to the edge of readability, and making the window the full width of the screen.

You'll find definitions for each column by browsing man top; COW, for instance, is the column that contains "copy on write faults," not some obscure reference to Clarus the Dogcow.

If you want to run top and have it only show certain columns, you can do that with the -stats option. For instance, this command will show processes in descending order of CPU usage, displaying only the process ID, command name, and CPU usage:

top -o CPU -stats PID,COMMAND,CPU

After adjusting to the changes, I've found the 10.6 version of top to be a great improvement over its predecessor.


Reprinted with permission from

For more Macintosh news, visit Macworld.com.
Story copyright 2009 Mac Publishing, LLC. All rights reserved.

Jump to comments

Apple

Additional Resources

WHITE PAPER
Approximately 60 percent of data migration projects overrun time or budget, while some fail completely. Download this white paper, "Enhancing Your Chance for Successful Data Migration," to learn the critical steps you need to take to execute a data migration project with minimum cost and risk to your business.
WHITE PAPER
Read the Gartner research note to learn why the TCO of a server-based computing deployment used to deliver all applications to users is around 50% lower than that of an unmanaged desktop deployment.
WHITE PAPER
Economic downturns have a tendency to accelerate emerging technologies, boost the adoption of effective solutions, and punish solutions that are not cost competitive or that are out of synch with industry trends. This IDC White Paper presents the results of an IDC survey of 330 companies in Western Europe, Asia/Pacific and the Americas that measures the receptiveness to Linux and takes into consideration changing views driven by the disruptive economic environment that businesses face today.

What People Are Saying

White Papers & Webcasts

IDC Webcast: Linux Adoption in a Global Recession
Access this webcast, compliments of Novell and HP, for a limited time only!

Network Operating System Evolution
Computerworld and Juniper invite you to download this white paper!  

How Operating Systems Create Network Efficiency
Computerworld and Juniper invite you to download the full report.  

Southern Company
Download Now