So I've been trying to run the following command to check the consumption by the firefox process.
top -b | grep "firefox"
Now I can see the desired output in terminal for it. But now when I try to export it to a file, I'm not able to. The command I'm running is:
top -b | grep "firefox" >> filename
or top -b | grep "firefox" > filename
Please help.
CodePudding user response:
You need the -n
parm for top
. For example,
top -b -n 1 | grep "httpd" >> httpd.out
Without -n 1
top
will keep processing and will never make it to grep
..
From the man page for top
:
-n :Number-of-iterations limit as: -n number
Specifies the maximum number of iterations, or frames, top
should produce before ending.
CodePudding user response:
You have to add in the command the flag -n Change the number of processes to show. You will be prompted to enter the number.
To take a snapshot of a specific process in top utility, execute command with the PID (-p) flag.
Also i recommed if you want to take snapshots for the process one (PID), and get taking three snapshots of the PID: top -p 678 -b -n3 > monitoring.out