'Apache2 rotatelogs not truncating file
I have rotatelogs setup how I believe it should be given my requirements. Below are the relevant lines:
CustomLog "|/usr/bin/rotatelogs -l -n 4 /var/www/html/org/logs/development/ssl.access_log 604800" combined
ErrorLog "|/usr/bin/rotatelogs -l -n 4 /var/www/html/org/logs/development/ssl.error_log 604800"
My understanding is that weekly, I should see a new log file get created with a different suffix. -n 4 would keep three weeks of logs plus the current file being written to. I only only seeing a ssl.access_log.1 and then the current log file. However, the log file without a suffix is massive and inspecting it's content I can see that there are messages from LONG ago.
Am I simply not grasping how rotatelogs functions?
UPDATE:
I'm beginning to wonder if the rotationtime argument to rotatelogs is specific to the time that the process has been running and not the time that the log file has been around. logrotate is ran daily via a cron job that ultimately picks up a default logrotate config file for apach2 which rotates the default log files and also reloads apache2 every morning at 0625. I am wondering if this reload is what causes my rotationtime argument of 604800 (7 days) to essentially never be reached thus causing the log file to never rotate. On the right track?
Solution 1:[1]
I'm observing exactly the same behaviour of rotatelogs: The file without suffix is never truncated, but still gets lines appended. In contrast to tczx3, I do not explicitely restart the processes regularly. Nor do I manupulate any timestamps. The behaviour is in my understanding clearly not like documented. And rotatelogs cannot count to 5 it seems. It is started with -n 5 but maintains only 4 files (without suffix, .1, .2 and .3). I manually removed the outdated lines now from the files without suffix and shall watch over the next weeks. According to what I'll see, I'll open a bug report.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ouflak |
