Skip to content
Advertisement

how to kill bottom n procceses in linux [closed]

By using pgrep python i can filter processes by PID:

[@~]$ pgrep python
725886
726128
726379
726816
732699
757708
769148

How can I kill first n processes in one line of code?

Advertisement

Answer

Filter and pass to kill.

pgrep python | head -n $n | xargs kill
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement