Reason why rotatelogs worked the first night but not again?

I'm using apache 2.2 on ubuntu 12.04. I set up the program rotatelogs to rotate my access log files on one of my virtual hosts. I followed the instructions I found here https://httpd.apache.org/docs/2.2/progr … elogs.html">https://httpd.apache.org/docs/2.2/programs/rotatelogs.html

under the #Log file locations section in my virtual host config I originally had the following code:

CustomLog /home/user/public/mysite.com/log/access.log combined 

Per the instructions from the apache docs in the above link I changed this code to:

CustomLog "| /usr/sbin/rotatelogs /home/user/public/mysite.com/log/access.log.%Y-%m-%d 86400" combined

Now it worked perfectly the first night. I checked the log folder at like 12:30 am and there was indeed a new access log file created called access.log.2014-09-20 But when I checked the log folder just now there is no new access log file for today. So yeah there is no access.log.2014-09-21 in my log folder. It was my understanding that adding 86400 would result in the creation of daily logs at midnight.

Any ideas as to what could have caused the program to not make a new log?

2 Replies

I'm not familiar with doing log rotation this way, but looking at the docs a couple possibilities come to mind.

  • All the examples don't have a space between the pipe symbol and the path to the program, while your configuration does. I don't know if this makes any difference or not.

  • The rotation is done at midnight UTC rather than local time (unless you specify the -l option or an offset value, which you haven't). So it may be happening at a different time than you expect.

> - The rotation is done at midnight UTC rather than local time (unless you specify the -l option or an offset value, which you haven't). So it may be happening at a different time than you expect.

You were right, it was the UTC time thing. For some reason I thought I was setting the time based on the server time zone or something. So the good news is that rotatelogs is working, it's just not working at the time I thought it would.

I'll look into adjusting the time with the -l option, etc.

Thanks.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct