Friday, June 27, 2014

Rotate Puppet-Dashboard delayed_job.log

There was a time where the delayed_job.log of the Puppet-Dashboard grew up to 8GB, so I had to find a solution, and this is it:

Edit the file: /etc/logrotate.d/puppet-dashboard and add the following lines:

# Puppet-Dashboard logs:
/usr/share/puppet-dashboard/log/delayed_job.log {
  daily
  rotate 7
  missingok
  compress
  delaycompress
  notifempty
  copytruncate
}
root@server:~# 

The, the logfiles will look like:

root@server:~# l /usr/share/puppet-dashboard/log/
total 1043256
drwxr-xr-x  2 www-data www-data       4096 Jun 27 05:10 ./
drwxr-xr-x 18 root     root           4096 Jun  4  2013 ../
-rw-r--r--  1 root     root         481078 Jun 27 11:33 delayed_job.log
-rw-r--r--  1 root     root        1811627 Jun 27 05:10 delayed_job.log.1
-rw-r--r--  1 root     root          78097 Jun 26 05:10 delayed_job.log.2.gz
root@server:~# 

A note for "copytruncate":
Truncate  the  original log file in place after creating a copy, instead of moving the old log file and optionally creating a new one,  It  can be used when some program can not be told to close its logfile and thus might continue writing (appending)  to  the previous log file forever.  Note that there is a very small time slice between copying the file and truncating it, so  some  logging  data  might be lost.  When this option is used, the create option will have no effect, as the old log file stays in  place.

Hope it helps! ;)