[LINUX] Kill specific python guys running together

There must be a better way.

This is the command you want to kill

$ ps aux
root     163622  0.0  0.3 229392 28852 ?        S     2019   0:00 /usr/bin/python3.5 imap.py

You can extract process with arguments with pgrep -a

$ pgrep -a python3.5 
125033 /usr/bin/python3.5 var.py        <----Not relevant python3.I want to exclude 5
125034 /usr/bin/python3.5 imap.py
125035 /usr/bin/python3.5 foo.py

Only those that hit the argument with grep

$ pgrep -a python3.5 | grep imap.py
125034 /usr/bin/python3.5 imap.py

Make it pid only

$ pgrep -a python3.5 | grep imap.py | awk '{print $1}'
125034
...

Kill it all together

kill $(pgrep -a python3.5 | grep imap.py | awk '{print $1}')

There must be a better way.

Recommended Posts

Kill specific python guys running together
Compare the Python array-like guys
Specify options when running python
Try running Python with Try Jupyter
Wrapper running Hadoop in Python