[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cobalt-users] Log rotation .. renaming rotated logs



I want to keep rotated logs for further offline processing. So I would 
like the rotated logs named somewhat according to the date they 
relate to...(for example : access_20020610.log.gz) 

I currently have this in /etc/logrotate.d/apache :

/var/log/httpd/access {
  prerotate
     /usr/local/sbin/split_logs web < /var/log/httpd/access
  endscript
  missingok
  postrotate
     /usr/bin/killall -HUP httpd 2> /dev/null || true
  endscript
  daily
}
.... So if the rotation takes place then there should be a file named 
access.1.gz in /var/log/httpd
If I would change the postrotate script to :

  postrotate
     /usr/bin/killall -HUP httpd 2> /dev/null || true
     mv /var/log/httpd/access1.gz /var/log/httpd/access_`date 
+'%Y%m%d'`.log.gz
  endscript

Would that work ?