Hi guys,

Couldn't find a suitable forum for this question, please move this thread if needed.

What I need to do redirect the output of TOP to a text file. Doing a simple
%> top > top.txt

yields the following

%> less top.txt
load averages: 0.88, 0.89, 0.87 11:50:49
100 processes: 99 sleeping, 1 on cpu

Memory: 64G real, 41G free, 13G swap in use, 53G swap free
---------------------------------------------------------------------------

As you can see, the CPU states are missing because the CPU states need a few seconds to be retrieved.

I tried the following command:

%> top -d 2 -s 5 > top.txt

which does give me the CPU states, but now I'm stuck with two outputs of TOP. I only want one.

Anyone have any idea's of how to capture the complete output of TOP on a UNIX machine?

thanks for your time,

tom.

Recommended Answers

All 3 Replies

Hey There,

top >outfile

captures everything for me running on

OpenBSD grex.cyberspace.org 4.1 GENERIC#0 i386

Do you get any spillover when you do the command? Perhaps adding output redirection would help on your terminal or OS:

top >out.txt 2>&1

Hope some of that helped :)

, Mike

Hey eggi,

there doesn't seem to be any spill over when executing your command. Running your command and looking at out.txt, all I have is the TOP output again without the CPU states.

:(

top -b -n 1 > whatever 2>&1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.