I'm attempting to write a mini-program/script/console command/not-sure-what-to-call-it that will record the CPU and memory usage of a given process, mostly just to teach myself how to use the functions involved (though if I manage it, it will potentially be useful in some coursework later in the year). Taking it in baby-steps, I'm currently trying to work out a console command that will display the details in the console.
My current thinking is that I can use
top,
grep the process name, and use
awk to pick out the details I want - for now, just the raw numbers.
Code:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2739 neko 20 0 479m 64m 33m S 6.0 1.8 29:26.77 clementine
Based on the above, my thinking is that I want to do
top | grep clementine | awk '{print $9, $10}' to achieve it. Doing this just returns a blank line, however.
Any suggestions as to what I should be doing instead?