Issue
Is it possible to kill all processes run in one directory? Processes have the same user.
For example (runing processes ):
/bin/1/a/p1
/bin/1/b/p2
/bin/2/a/p3
And I want kill all processes from /bin/1/
(/bin/1/a/p1
and /bin/1/b/p2
).
Solution
You can say:
ps aw | awk '/\/bin\/1\// {print $1}' | xargs kill -9
EDIT: In order to ensure that this doesn't kill any unintended command as commented you could say:
ps aw o pid,command | awk '$2 ~ /^\/bin\/1\// {print $1}' | xargs kill -9
Answered By - devnull Answer Checked By - Candace Johnson (WPSolving Volunteer)