5.8 Stopping Squid

The safest way to shut down Squid is with the squid -k shutdown command:

% squid -k shutdown

This command sends the TERM signal to the running Squid process. Upon receipt of the TERM signal, Squid closes its incoming sockets so that new requests aren't accepted. It then waits some amount of time for outstanding requests to complete. The default is 30 seconds, which you can change with the shutdown_lifetime directive.

If, for some reason, the squid.pid file is missing or unreadable, the squid -k commands don't work. In this case, you can manually kill Squid by finding the process ID with ps. For example:

% ps ax | grep squid

If you see more than one Squid process, be sure to kill the one that shows up as (squid). For example:

% ps ax | grep squid

  294  ??  Is     0:00.01 squid -sD

  296  ??  S      0:00.27 (squid) -sD (squid)

% kill -TERM 296

After sending the TERM signal, you may want to watch the log file to double-check that Squid is shutting down:

% tail -f logs/cache.log

2003/09/29 21:49:30| Preparing for shutdown after 9316 requests

2003/09/29 21:49:30| Waiting 10 seconds for active connections to finish

2003/09/29 21:49:30| FD 11 Closing HTTP connection

2003/09/29 21:49:31| Shutting down...

2003/09/29 21:49:31| FD 12 Closing ICP connection

2003/09/29 21:49:31| Closing unlinkd pipe on FD 9

2003/09/29 21:49:31| storeDirWriteCleanLogs: Starting...

2003/09/29 21:49:32| Finished.  Wrote 253 entries.

2003/09/29 21:49:32| Took 0.1 seconds (1957.6 entries/sec).

2003/09/29 21:49:32| Squid Cache (Version 2.5.STABLE4): Exiting normally.

If you use squid -k interrupt, Squid shuts down immediately, without waiting for active requests to complete. This is equivalent to sending the INT signal with kill.

    Appendix A. Config File Reference