2

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
}
3
  • 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. Jul 18, 2019 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? Jul 18, 2019 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. Jul 18, 2019 at 14:06

1 Answer 1

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.

1
  • 2
    What ... is the answer?
    – Jeff Schaller
    Sep 6, 2019 at 13:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .