logrotate with option dateext adds timestamp of tommorrow to a file rotated today

Latest response

Hello,

Today I have a question regarding logrotate with the option dateext (see logrotate(8)). The following example should illustrate the scenario I found on one of my hosts:

-rw-------. 1 root    root       4302 Mar  9 06:00 maillog
-rw-------. 1 root    root       5011 Feb 10 06:00 maillog-20180211
-rw-------. 1 root    root       5723 Feb 18 06:00 maillog-20180219
-rw-------. 1 root    root       4296 Feb 24 06:00 maillog-20180225
-rw-------. 1 root    root       6068 Mar  3 06:00 maillog-20180304
-rw-------. 1 root    root     443818 Mar  9 13:14 messages
-rw-------. 1 root    root     582574 Feb 11 03:45 messages-20180211
-rw-------. 1 root    root     672321 Feb 19 03:24 messages-20180219
-rw-------. 1 root    root     491993 Feb 25 03:07 messages-20180225
-rw-------. 1 root    root    1255279 Mar  4 03:39 messages-20180304

As you can see a string with a timestamp is attached to the rotated logfiles. And in case of the messages log the dateext string it the expected from the day the log was rotated.

But in case of the maillog dateext adds a string were the timestamp is from one day in the future. My question: "Why that?"

The above is only an example. I have some more logs where the timestamp is from the future. Do someone know how this happens?

My /etc/logrotate.conf looks like:

weekly
rotate 4
create
dateext
include /etc/logrotate.d

Best regards,
Joerg K.

Responses

The timestamp of the rotated file is the time it was changed for the last time and the timestamp in the file name is the time of the rotate:

# ls -l yum.log*
-rw-------.  1 root   root       29099 Dec  3 22:51 yum.log-20180101
-rw-------.  1 root   root         147 Feb 26 14:30 yum.log
# tail -1 yum.log-20180101
Dec 03 22:51:41 Updated: policycoreutils-python-2.5-17.1.el7.x86_64
# head -1 yum.log
Jan 17 11:51:47 Updated: scc-1.24.150-1.noarch

Thanks for your answer. :-)

Thanks a lot.

Hi, I hv a logrotate issue , for all logs except one log, log rotate add dateext as ".YYYYMMDD" , where as for all others it add as "-YYYYMMDD". I am using dateext option in logrotate.conf and file under logrotate.d/app-log files. due to this different dateext ".YYYYMMDD", file is not compressed.

Could you please suggest.