I prefer the following so I can still use top interactively without having to look up the pids each time I run it:
top -p `pgrep process-name | tr "\\n" "," | sed 's/,$//'`
Of course if the processes change you’ll have to re-run the command.
Explanation:
pgrep process-namereturns a list of process ids which are separated by newlinestr "\\n" ","translates these newlines into commas, because top wants a comma-separated list of process idssedis a stream editor, andsed 's/,$//'is used here to remove the trailing comma