0

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
}
egorgry
  • 2,871
  • 2
  • 23
  • 21

1 Answers1

3

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.

mdpc
  • 11,856
  • 28
  • 53
  • 67