我读过这些关于 maxage 和旋转结合使用的博客,但我仍然对此感到困惑。
https://www.net7.be/blog/article/configuring_logrotate.html
https://man7.org/linux/man-pages/man8/logrotate.8.html
我想象这样一个场景。
{
daily
rotate 10
maxage 5
}
First day:
application.log
rotation_count=1<10=>do nothing
age_of_oldest_log=0 days<5=>do nothing
Second day:
application.log
application.log_first_day
rotation_count=2<10=>do nothing
age_of_oldest_log=1 days<5=>do nothing
Third day:
application.log
application.log_first_day
application.log_second_day
rotation_count=3<10=>do nothing
age_of_oldest_log=2 days<5=>do nothing
Fourth day:
application.log
application.log_first_day
application.log_second_day
application.log_third_day
rotation_count=4<10=>do nothing
age_of_oldest_log=3 days<5=>do nothing
Fifth day:
application.log
application.log_first_day
application.log_second_day
application.log_third_day
application.log_fourth_day
rotation_count=5<10=>do nothing
age_of_oldest_log=4 days<5=>do nothing
Sixth day:
application.log
application.log_first_day
application.log_second_day
application.log_third_day
application.log_fourth_day
application.log_fifth_day
rotation_count=6<10 =>do nothing
age_of_oldest_log=5 days!<5=>delete the oldest log application.log_first_day
Seventh day:
application.log
application.log_second_day
application.log_third_day
application.log_fourth_day
application.log_fifth_day
application.log_sixth_day
rotation_count=7<10 => do nothing
age_of_oldest_log=5!<5=>delete the oldest log application.log_second_day
Eighth day:
application.log
application.log_third_day
application.log_fourth_day
application.log_fifth_day
application.log_sixth_day
application.log_seventh_day
rotation_count=8<10=>do nothing
age_of_oldest_log=5!<5=>delete the oldest log application.log_third_day
Ninth day:
application.log
application.log_fifth_day
application.log_sixth_day
application.log_seventh_day
application.log_eighth_day
rotation_count=9<10=>do nothing
age_of_oldest_log=5!<5=>delete the oldest log application.log_fourth_day
Tenth day:
application.log
application.log_seventh_day
application.log_eighth_day
application.log_ninth_day
rotation_count=10!<10=>remove the oldest file after 10 rotations thusremove application.log_fifth_day
age_of_oldest_log=4!<5=>do nothing.
Eleventh day:
application.log
application.log_eighth_day
application.log_ninth_day
application.log_ninth_day
rotation_count=11!<10=>remove the oldest log file ie application.log_seventh_day
age_of_oldest_log=3<5=>do nothing.
Is this how it works? Or am I missing something?