4bb774de244da2d6e7f39a189b905077

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.

1
ps ax | grep "nginx: master" | xargs -I % ruby -e 'exec "sudo kill #{"%".split(/\s/).first}"'

Refactorings

No refactoring yet !

Bfec5f7d1a4aaafc5a2451be8c42d26a

macournoyer

June 27, 2008, June 27, 2008 17:13, permalink

No rating. Login to rate!

Replace /usr/local/nginx/ w/ the path to your Nginx installation

1
sudo kill -INT `cat /usr/local/nginx/logs/nginx.pid`
55fd56dfef815d7aa543be09ad3ed3e9

Kamil Kisiel

June 27, 2008, June 27, 2008 19:47, permalink

No rating. Login to rate!

I prefer to just use killall

1
killall nginx
Bfec5f7d1a4aaafc5a2451be8c42d26a

macournoyer

June 27, 2008, June 27, 2008 19:59, permalink

No rating. Login to rate!

Not sure it's a good idea, master process controls worker procesess, that could cause some worker to loose connections.

F200b43dd7a12345e2d46d7256b4cfe6

Jay R Wren

June 27, 2008, June 27, 2008 20:15, permalink

No rating. Login to rate!

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}'`

F200b43dd7a12345e2d46d7256b4cfe6

Jay R Wren

June 27, 2008, June 27, 2008 20:16, permalink

No rating. Login to rate!

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}'`

9d8de42cebeeaf6d223d86bb9130832b

gms8994

June 27, 2008, June 27, 2008 21:10, permalink

No rating. Login to rate!

There's always the following as well.

1
ps ax | grep 'nginx: master' | awk '{print $1}' | xargs kill
B5603dc8f1e87c251bf9b1d28f31d38f

mrxinu

June 28, 2008, June 28, 2008 03:24, permalink

No rating. Login to rate!

Combining Jay and gms8994's suggestions:

1
kill $(ps ax | awk '/nginx: master/ {print $1}')
0706636fd5e30fa66019d7ffacdb5b11

Marco Valtas

June 28, 2008, June 28, 2008 04:13, permalink

1 rating. Login to rate!

In Linux check the "pkill" command.

[bash]

1
2
pkill "nginx: master"
Dceec62d5ed81c8405b72a4978b7b70a

Oscar Carlsson

June 29, 2008, June 29, 2008 12:15, permalink

No rating. Login to rate!

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)

Your refactoring





Format Copy from initial code

or Cancel