I want to periodically monitor the CPU usage and plot in time series. Not having much knowledge, I plan to use the top command, something like this question (Monitor cpu usage (and perhaps memory using) for a single process simple as possible). However, when I issue command like "top -c -p PID", I want it to output then exit automatically without manually type q or ctrl-c. And if not using top, what other command can achieve the same function without interactivity?
Asked
Active
Viewed 51 times
0
-
1maybe look at sysstat package for tools related to collecting system metrics. – Tom Mar 30 '23 at 18:49
-
1PS can do also the job – djdomi Mar 30 '23 at 19:36
2 Answers
1
If you want to monitor the things for particular process you can use command:
ps -flp <PID>
if you want to monitor overall performance of the system you can use vmstat
from sysstat
package:
vmstat 1 2
and get the second line (first is average from the server start)

Romeo Ninov
- 5,263
- 4
- 20
- 26
0
From "man top", I find that using the option "-b" and "-n" can solve the issue.

user180574
- 225
- 1
- 3
- 12