kill -9 `ps -eo pid,command | grep 'gunicorn.*${moduleName:appName}' | grep -v grep | sort | head -1 | awk '{print $1}'`
ps -eo pid,command
will only fetch process id, command and args out
grep -v grep
to get rid of output like 'grep --color=auto xxx'
sort | head -1
to do ascending sort and get first line
awk '{print $1}'
to get pid back
One more thing you may need to pay attention to: Where gunicorn is installed and which one you're using?
Ubuntu 16 has gunicorn installed by default, the executable is gunicorn3 and located on /usr/bin/gunicorn3, and if you installed it by pip, it's located on /usr/local/bin/gunicorn. You would need to use which gunicorn
and gunicorn -v
to find out.