Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is it possible to force logrotate to use UTC time for one configuration? I need the dateext to be set to UTC. I was hoping it was as simple as setting a date varible. Should I just run postrotate and mv the files to a new file name that puts the UTC time on after the fact. I'm just looking for a best practice or the most practical solution. Thanks in advance.

My cute attempt to cheap out with a setting a variable. :)

/var/log/bricks/*.log {
DATE=`date -u +%Y%m%d`
missingok
notifempty
copytruncate
daily
dateext
dateformat .%Y%m%d
compress
}
share|improve this question

1 Answer 1

up vote 3 down vote accepted

Have you thought of generating two configurations and run logrotate normally for one configuration.

For the UTC configuration, run logrotate through a wrapper:

  #! /bin/sh
  TZ=UTC
  export TZ
  PATH=/bin:/usr/bin:/sbin:/usr/sbin
  export PATH
  logrotate -s /var/lib/gmt-logrotate.status gmt-logrotate.cfg
  exit $?

By breaking them up, you can seperate the times you run each of the logrotate configurations.

share|improve this answer
    
Very smart. I didn't think of that. I'll look into it since it will give me a little more flexibility. –  egorgry Feb 14 '12 at 18:01
    
just implemented this and it works like a charm. Thanks! –  egorgry Feb 14 '12 at 21:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.