I want redirect top
output to a file, but I am interested in the per-CPU usage.
Doing just
#I only want to see processes belonging to myuser
top -b -d 1 -u myuser > top.txt
gives me stats with all the CPUs usage combined.
Running just top
and then pressing 1
makes top break out per-CPU usage. How do I redirect this to the file?
I've seen some related questions:
How can I receive top-like CPU statistics from the shell?
How to stream top snapshot into file?
But not found the answer to how to make the part of the command before the redirect operator take the 1
that top needs for per-CPU stats.
mpstat -P all
? This gives similar output to the CPU section in to.top
, but so far didn't no luck.top
. Which are you using? You can typically find out withtop -v
.