I am trying to figure out if there is a way to kill all processes by name and user. E.g. I want to kill all the Java instances run by user myuser.
As of the moment I do:
$ pgrep -u myuser java
2185
3281
3413
3504
22534
26174
27554
which gives a list of the pid of java run by mysuer. Then I kill each pid individually. Is there a better way to do this?
Thanks in advance!
Use killall(1)
:
killall -u myuser java
Note that you may need to do this via sudo
, and you may need -9
to kill processes that swallow SIGTERM
:
sudo killall -9 -u myuser java
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With