Score:0

How to use top without interactivity?

ca flag

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?

ng flag
Tom
maybe look at sysstat package for tools related to collecting system metrics.
djdomi avatar
za flag
PS can do also the job
Score:1
in flag

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)

Score:0
ca flag

From "man top", I find that using the option "-b" and "-n" can solve the issue.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.