0

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?

user180574
  • 225
  • 1
  • 3
  • 12

2 Answers2

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