Keep Your Apache Server Logs In Check

If you’re using Awstats to analyse server logs then the originals can be removed once they’ve been processed. The bash script below removes all of the files found in /var/log/apache2. Running this as a daily cron job ensures that your server doesn’t become bloated.

#!/bin/bash
cd /var/log/apache2
for file in `find .`
do
    if [ -f $file ];
    then
        cat /dev/null > $file
    fi
done