I have many processes running by name gunicorn
ubuntu 23884 0.0 7.1 190092 71980 ? S Sep10 0:01 gunicorn: worker [ll1]
ubuntu 23885 0.0 6.8 187120 69128 ? S Sep10 0:01 gunicorn: worker [ll1]
ubuntu 23886 0.0 7.1 189800 71712 ? S Sep10 0:01 gunicorn: worker [ll1]
I want to kill all proccess by name gunicorn.Currently i am able to kill only one process by this script at a time.
#!/bin/bash
pid=`ps ax | grep gunicorn | awk '{split($0,a," "); print a[1]}' | head -n 1`
echo $pid
kill $pid
echo "killed gunicorn"