Loading ...
Sorry, an error occurred while loading the content.
 

Cron Job for cleaning log files

Expand Messages
  • Guillermo Carrion
    I want to create a Cron Job for cleaning my access log file on my apache web server. Because I have my new server and I haven t created a a Cron Job for delete
    Message 1 of 2 , Jun 7, 2001
      I want to create a Cron Job for cleaning my access log file on my apache web
      server. Because I have my new server and I haven't created a a Cron Job for
      delete the log file and is getting quite big. Right now is over 1GB.
      I looked at the folder /var/log/httpd/ and found the following files named
      access_log:
      access_log - Size: 63MB
      access_log.1 - Size: 1186MB
      access_log.2 - Size: 710MB
      access_log.3 - Size: 301kb

      I want it to clear the log file every Sunday at 4:15am, Because I run
      webalizer every day at 4:00am and want to maintain the stats as accurate as
      possible.

      Thanks for the help
      Guillermo Carrion
    • juaid
      If you use logrotate, it does this for you automatically, rotating the logs the times you specify.. I m not sure what the default is, if it is to rotate them
      Message 2 of 2 , Jun 8, 2001
        If you use logrotate, it does this for you automatically, rotating the logs
        the times you specify..
        I'm not sure what the default is, if it is to rotate them every one week, or
        what (check man logrotate), but you can specify it adding a "daily",
        "weelky" or "monthly" statement...

        Teher's also a postrotate statement that makes a kill -HUP for the server to
        read the new log files and not to continue pointing to the handlers of the
        old ones..

        you can also tell logrotate, how many times you want to rotate the logs by
        adding a line for example "rotate 4" which makes it to rotate the logs 4
        times, so after rotating you'll see that you have the acces_log file, and
        access_log.1, access_log,2, etc

        you should have for exapmle a file called /etc/logrotate.d/apache
        with the following:

        /var/log/httpd/access_log {
        missingok
        postrotate
        /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null ||
        true
        endscript
        }

        /var/log/httpd/agent_log {
        missingok
        postrotate
        /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null ||
        true
        endscript
        }

        /var/log/httpd/error_log {
        missingok
        postrotate
        /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null ||
        true
        endscript
        }

        /var/log/httpd/referer_log {
        missingok
        postrotate
        /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null ||
        true
        endscript
        }

        cheers

        juaid



        ----- Original Message -----
        From: "Guillermo Carrion" <techtv@...>
        To: <webalizer@yahoogroups.com>
        Sent: Friday, June 08, 2001 1:03 AM
        Subject: [webalizer] Cron Job for cleaning log files


        I want to create a Cron Job for cleaning my access log file on my apache web
        server. Because I have my new server and I haven't created a a Cron Job for
        delete the log file and is getting quite big. Right now is over 1GB.
        I looked at the folder /var/log/httpd/ and found the following files named
        access_log:
        access_log - Size: 63MB
        access_log.1 - Size: 1186MB
        access_log.2 - Size: 710MB
        access_log.3 - Size: 301kb

        I want it to clear the log file every Sunday at 4:15am, Because I run
        webalizer every day at 4:00am and want to maintain the stats as accurate as
        possible.

        Thanks for the help
        Guillermo Carrion


        To unsubscribe from this group, send an email to:
        webalizer-unsubscribe@egroups.com
        Webalizer homepage: http://www.webalizer.org
        Webalizer for NT: http://www.medasys-lille.com/webalizer/




        Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
      Your message has been successfully submitted and would be delivered to recipients shortly.