1

I am about to use logrotate for the first time, I went through man page and some web guides.

I am trying to achieve rotation every week and deletion of the logs that are older than 7 days (I want to keep only 7 days history).

I am worried if the "maxage" should not be set to 8 days so I do not come to state where there are no logs left (log is about to be rotated on weekly basis but it is considered 7 days old so it is deleted instead of rotated).

My logrotate file looks like this:

/var/log/airflow/*/*.log {
  # rotate log files weekly
  weekly
  # keep 1 week worth of backlogs
  rotate 1
  # remove rotated logs older than 7 days
  maxage 7
  missingok
}
  • 1
    How would you have no logs left? It's only deleting logs that are older than 7 days so all of the logs that aren't as old will still be there. – Nasir Riley Jul 18 at 10:01
  • @NasirRiley Lets say it is the first week of logs, first logs are created. After one week logrotate runs, are not the logs created now considered one week old and deleted? – Ondřej Doležal Jul 18 at 11:55
  • 1
    It says to delete logs that are older than seven days. On the eight day, only the first log that was ever created will be deleted as it will the only one that's older than seven days. The rest won't be seven days old yet so they won't be deleted. – Nasir Riley Jul 18 at 14:06
0

As @Nasir said: "It says to delete logs that are older than seven days. On the eight day, only the first log that was ever created will be deleted as it will the only one that's older than seven days. The rest won't be seven days old yet so they won't be deleted".

Hence my config file is correct.

Everything is clear now, thanks @Nasir for your help. Marking as answered.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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