Monthly Archives: August 2014

Take backend out of rotation in varnish

When using Varnish and multiple backends it’s sometimes convenient to remove a particular backend without restarting the service Please note that this requires a Varnish version of at least 3.0.3 to work.

To remove a backend issue the following commands:

root@lb-01:~# varnishadm -T localhost:6082 -S /etc/varnish/secret
varnish> backend.set_health backend01 sick
200
varnish>

To re-add it to rotation use the following commands:

root@lb-01:~# varnishadm -T localhost:6082 -S /etc/varnish/secret
varnish> backend.set_health backend01 auto
200
varnish>

backend01 are backend name that can be required by issuing backend.list in the Varnish cli.

Killing specific processes with ps, grep, awk and xargs

Often when you work with Linux you need to kill a bunch of processes matching a certain pattern. This could be accomplished using ps, grep, awk and xargs like this:

ps -aux |grep php-fpm |grep -v grep | awk '{print $2}' | xargs kill

If the process won’t die you could add -9 to kill which can’t be blocked by anything. Of course you need to own the processes you try to kill (or use sudo).

References:
Article on commandlinefu.com