How do I reset my SWS server's log files?

Sooner or later, you'll want to reset your log files (accesslog and errorlog) because they are too big, or full of old information you don't need. The access.log typically grows by 1Mb for each 10,000 requests. Most people's first attempt at replacing the logfile is to just move the logfile or remove the logfile. This doesn't work. Apache will continue writing to the logfile at the same offset as before the logfile moved. This results in a new logfile being created which is just as big as the old one, but it now contains thousands (or millions) of null characters. The correct procedure is to move the logfile, then signal Apache to tell it to reopen the logfiles.

Apache is signaled using the SIGHUP (-1) signal. e.g.

mv accesslog accesslog.old kill -1 `cat httpd.pid`

Note: httpd.pid is a file containing the process id of the Apache httpd daemon, Apache saves this in /var/run/.

Many people use this method to replace (and backup) their logfiles on a nightly or weekly basis.

References

1. rfc931

2. http://www.w3.org/Daemon/User/Config/Logging.html#common-logfile-format