This guide shows you how to use the varnishadm command in your system crontab to automate Varnish cache purging.
Access your server as root or switch to the root user. If you installed Varnish from a repo you will have all the Varnish utility commands installed as well. You need to make sure that varnishadm is installed so run the command now. You will get an output asking you for switches and arguments. This is correct.
usage: varnishadm [-t timeout] [-S secretfile] -T [address]:port command [...]
Before going any further you may wish to read over the varnishadm manual pages, just to familiarise yourself with the command.
As you can see from the man page you need to specify the host and secret file for issuing varnishadm commands. To purge the cache on local host you can use the following command.
varnishadm -T localhost:6082 -S /etc/varnish/secret url.purge .
Let’s break this command apart.
varnishadm -T localhost:6082