Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi guys. Im trying to capture top output but it doesnt seem to be an easy task:
- Saving top output with redirect sign (>) gives me binary file and very hard to read format.
- If I run top in batch mode (-b), it seems providing me an incorrect output. I let top run for 1 hour, and the cpu info is exactly the same. For 1 hour, the idle percentage is always 87.9% :S
So, what would be the best way to log top output? Thanks.
Perhaps you'd better share (some more of) your script with us. I regularly use top in batch saving to a file in a timed loop for diagnostics.
Better would be something like sar of course.
Edit: didn't see it was the OP posting code above me. You need to take the 2nd pipe out of that command or it will not produce any output to the file. Maybe that's a typo as you said you were getting some output - but I just copied/pasted your code and it behaved as expected, with different output for each execution of top.
Are you sure the no change is actually incorrect? Try putting a heavy load on your CPU and see what happens. I am a bit suspicious, viewing the output of top in normal mode I get bigger changes, going up to 20%us even when I'm not doing anything.
Hmmm - I thought I had already responded to this, but obviously not.
I presume top suffers the same "problem" as vmstat (see the manpage). On that basis, I only use "-n 1" when I am looking at the individual process data, not the summary data at the beginning of the display. Hence I use a decent iteration count, and loop based on a timer - say
Code:
for i in `seq 1 10` ; do top -b -n 8 -d 3 >> data.top ; sleep 300 ; done
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.