1
ps ax | grep "nginx: master" | xargs -I % ruby -e 'exec "sudo kill #{"%".split(/\s/).first}"'
Refactorings
No refactoring yet !
macournoyer
June 27, 2008, June 27, 2008 17:13, permalink
Replace /usr/local/nginx/ w/ the path to your Nginx installation
1
sudo kill -INT `cat /usr/local/nginx/logs/nginx.pid`
Kamil Kisiel
June 27, 2008, June 27, 2008 19:47, permalink
I prefer to just use killall
1
killall nginx
macournoyer
June 27, 2008, June 27, 2008 19:59, permalink
Not sure it's a good idea, master process controls worker procesess, that could cause some worker to loose connections.
Jay R Wren
June 27, 2008, June 27, 2008 20:15, permalink
awk is lighter weight than invoking a ruby process, and it the traditional way I've seen this pattern implemented.
kill `ps ax | grep "nginx: master" | awk '{print $1}'`
Jay R Wren
June 27, 2008, June 27, 2008 20:16, permalink
awk is lighter weight than invoking a ruby process, and it the traditional way I've seen this pattern implemented.
kill `ps ax | grep "nginx: master" | awk '{print $1}'`
gms8994
June 27, 2008, June 27, 2008 21:10, permalink
There's always the following as well.
1
ps ax | grep 'nginx: master' | awk '{print $1}' | xargs kill
mrxinu
June 28, 2008, June 28, 2008 03:24, permalink
Combining Jay and gms8994's suggestions:
1
kill $(ps ax | awk '/nginx: master/ {print $1}')
Marco Valtas
June 28, 2008, June 28, 2008 04:13, permalink
In Linux check the "pkill" command.
[bash]
1 2
pkill "nginx: master"
Oscar Carlsson
June 29, 2008, June 29, 2008 12:15, permalink
This is how I restart my nginx master process (like after changing my configurations), but you can use it to kill the process if you remove '-HUP'.
You might want to substitute '/var/run/nginx.pid' with where your pid-file is located, but it should be the same on most systems.
1
kill -HUP $(cat /var/run/nginx.pid)
hi,
i am not expert on linux shell command, however i was trying to kill nginx master process.
i hope you guys can suggest me better simplified version.
best wishes.