PID %CPU %MEM COMMAND
719011 ---- -- 0 ---- --- ---- - 0.7 1.3 606:58.25 dvaudio_server
719012 ---- -- 0 ---- --- ---- - 0.7 1.3 606:58.25 dvaudio_server
719013 ---- -- 0 ---- --- ---- - 0.7 1.3 606:58.25 dvaudio_server
719014 ---- -- 0 ---- --- ---- - 0.7 1.3 606:58.25 dvaudio_server
719015 ---- -- 0 ---- --- ---- - 0.7 1.3 606:58.25 dvaudio_server
719016 ---- -- 0 ---- --- ---- - 0.7 1.3 606:58.25 dvaudio_server
Is it possible to achieve the above result from top just by issuing an accumulation of commands piped together then saving to a file?
I have tried various ways but all give messy results.
Is there anyway of getting this information only using the pPID? This will then save having to write every child-PID in the command!
TLDR
Long answer
You could use the
-b
option oftop
:This basically makes
top
non-interactive. You can then pipe any command as you wish, and redirect the output to a file of your choice.As said in the man, you may want to use the
-n
option in order to not to have to kill the process. If you want the process to stop as soon as it shows the result, use the-n 1
value.sed -'1,6d'
will get rid of the ressources usage summary (the first 6 lines of the output).Edit
Possible duplicate of get
top
output for non interactive shell.