find and terminate processes

The arguments for pgrep and pkill are interchangeable - tune your regexes with pgrep, then terminate processes with pkill

Examples

Find all processes owned by root where the full command matches perl ./tests/, then terminate them:

sudo pgrep -u root -f 'perl ./command'

sudo pkill -u root -f 'perl ./command'

References

https://www.computerhope.com/unix/upgrep.htm