Linux command collection
2024/02/21My notes about Linux commands
Linux
Cover image thanks toWilson montoya


Process

pkill

To kill a process by its name

shell
pkill python2

pgrep

Get the pid like using grep

shell
pgrep python2

>>> 11123

By process name and its parameters, we use -f, which means 'full'

shell
pgrep -f "python2 test.py*"

Use pgrep with kill

shell
kill -9 $(pgrep -f "python2 test.py*")
Designed & Coded by Tianyu @2022~2024