Networking, Programming and Graphics Tutorials
Home >> OS >> Linux >> System >>

Setup Logrotate [2/2]

We will create a file called /etc/logrotate.d/httpd. Below is the configuration file that i have set in logrotate for this service. Next paragraph i will explain in details each logrotate directive I have used.

/var/log/httpd/*log {
      weekly
      rotate 5
      copytruncate
#     compress
      missingok
      notifempty
#      sharedscripts
      postrotate
        /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true
      endscript
}
# That is where my logs are being saved.
/var/log/httpd/*log {

# rotate log files weekly
weekly

# rotates keeps logs for 5 weeks then overwrites.
rotate 5

# tells logrotate not to rotate a log if it's already empty
notifempty

# tells logrotate not to issue an error if the log file is missing
missingok

# The rotating scripts are only run once, no matter how many logs match the wildcarded pattern.
sharedscripts

# contains a block of instructions on what logrotate should do after the logs have been rotated. In our case we kill apache server so we can make it work with the new log files.
postrotate
/bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true
endscript
}

[ib] Additional useful parameters [/ib]:

copytruncate - copytruncate tells logrotate to copy and truncate the original log file in place instead of renaming it and creating a new logfile. Some programs work better with this behavior

compress - tells logrotate to compress old logs when they are rotated

Rate this tutorial:                    
Networking, Programming and Graphics Tutorials - Setup Logrotate [2/2] - Networking, Programming and Graphics Tutorials

Need a specific tutorial? Do not hesitate and submit a request!
Related Tags: Setup Logrotate  setup logrotate  setup when logrotate is called  logrotate .1  how to set up logrotate  logrotate how to  logrotate tutorial example  logrotate exclude log  how to custom logrotate  custom logrotate  logrotate tutorial  logrotate exclude  plesk logrotate  logrotate copytruncate nulls  Plesk configure logrotate  logrotate exclude file  logrotate custom config  custom logrotate application  plesk logrotate config file  ccproxy setup