Squid_ The Definitive Guide - Duane Wessels [32]
% squidclient http://www.squid-cache.org/
If this works, Squid's home page HTML file will scroll across your terminal window. Once you're confident that Squid works okay, you can interrupt the Squid process (i.e., with Ctrl-C) and run Squid as a daemon.
Running Squid as a Daemon Process
Normally you'll want to run Squid as a daemon process (i.e., not attached to your terminal window). The easiest way to do this is simply execute Squid as follows:
% squid -s
The -s option causes Squid to write important status and warning messages to syslogd. Squid uses the LOCAL4 facility and the LOG_WARNING and LOG_NOTICE priorities. Your syslog daemon may or may not actually log Squid's messages, depending on how it is configured. These same messages are written to the cache.log file, so it is safe to omit the -s option if you prefer.
When you start Squid without the -N option (as shown earlier), Squid automatically backgrounds itself and creates a parent/child process pair. The child process is the one that does all the real work. The parent process makes sure that a child process is always running. Thus, if the child process dies unexpectedly, the parent starts another so that Squid remains in operation. You can see this parent/child process interaction by looking at your syslog messages:
Jul 31 14:58:35 zapp squid[294]: Squid Parent: child process 296 started
Here you can see that the parent is process ID 294, and the child is 296. When you look at ps output, you'll see that the child process is listed as (squid):
% ps ax | grep squid
294 ?? Is 0:00.01 squid -sD
296 ?? S 0:00.27 (squid) -sD (squid)
If the child Squid process dies unexpectedly, the parent starts another. For example:
Jul 31 15:02:53 zapp squid[294]: Squid Parent: child process 296 exited due to signal 6
Jul 31 15:02:56 zapp squid[294]: Squid Parent: child process 359 started
In some situations, the child Squid process may die immediately. Rather than constantly spawning new Squid processes, the parent process gives up if the child processes won't stay running for at least 10 seconds five times in a row:
Jul 31 15:13:48 zapp squid[455]: Squid Parent: child process 474 exited with status 1
Jul 31 15:13:48 zapp squid[455]: Exiting due to repeated, frequent failures
If this happens to you, check syslog and Squid's cache.log for error messages.
The squid_start Script
When Squid runs as a daemon process, it looks for a file named squid_start in the same directory as the squid binary. If found, this program is executed before the parent process forks to run the child process. You can use this script for certain administrative tasks, such as notifying someone that Squid is starting, managing log files, etc. Squid doesn't start the child process until the squid_start program exits.
* * *
Note
The squid_start script only works when you start Squid by its absolute or relative pathname. In other words, Squid doesn't use the PATH environment variable to locate squid_start. Thus, you may want to develop the habit of starting Squid like this:
% /usr/local/squid/sbin/squid -sD
rather than starting Squid like this:
% squid -sD
* * *
Boot Scripts
Most likely, you'll want Squid to start automatically every time your computer boots. Different operating systems vary widely in how their boot-up scripts work. I'll describe some common environments here, but you may need to refer to your particular operating system for specific information.
/etc/rc.local
One of the easiest schemes is the /etc/rc.local script. This is simply a shell script that runs as root each time the system boots. Using this script to start Squid is as easy as adding the following line:
/usr/local/squid/sbin/squid -s
Of course your installation prefix may be different, and you may like to use some other command-line options. Don't use the -N option here.
If, for some reason, you're not using the cache_effective_user directive, you can try using su to start Squid as a non-root user:
/usr/bin/su