How to monitor Memory and CPU usage of the single process by program/executable name(not PID);
2 Answers
Try this. if you want with program name
mypid=`pidof programname` ; top -p $mypid
OR
top -p `pidof programname`
To monitor one or more instances matching the name:
top -p$(pgrep <program> | tr '\n' ',' | head -c -1)
Use pgrep -f
to search the whole command lines for matches.
(Works with htop
too.)
top -p PID