Reputation: 303
Im trying to get cpu/mem usage from one of processes running on my machine. I'm using command:
top -b -p <PID> > some_file.txt
but it's giving me only the current utilization of one CPU. I know that in interactive mode I can use 1
to display all of my cpu's, but is there a way to achieve that in batch mode?
Upvotes: 2
Views: 13269
Reputation: 161
If you do "$man top" you can see " t option" for 4 way toggle. Use the option.
Steps to display cpu usage bar. 1. run top command 2. press 1 to list the cpu usage. 3. press "t" twice to display cpu usage bar.
Upvotes: 4
Reputation: 303
Ok, this was kind of fast :) This issue can be resolved in following steps:
start top
in interactive mode (form me, as I wanted to get the correct process to be shown - top -p <PID>
press 1
to display all cpu's utilization
press W
to save the configuration
Now, as I found, top
in batch mode uses file .toprc
as a configuration file. When You save your configuration in interactive mode, You can use this file later on. So now, when it is saved, You can use top -b -p <PID> > some_file.txt
and it will gather information about both cpu's utilization.
Upvotes: 3