I am new to Linux/CentOS and right now I am running into a little problem.
My CentOS7 Server logs all Maillogs, via Logrotate, on a daily basis and moves them to the folder /var/log/old_maillogs. Right now the logs are saved with a name similar to this:
Maillog-20230721
I would like their names to change, based on how old they are, so that if the Log is one day old it's named:
Maillog-1
And one the day after that, the files name changes to:
Maillog-2
And so on.
Is this even possible, if so, what would be the smartest way to get it working? I have read a lot about scripts that get executed once per day, but then again, how do I code the script, so that it recognizes how many logs are in the folder?
This is my current config:
/var/log/maillog{ daily rotate 365 postrotate Systemctl restart rsyslog.service endscript mailfirst olddi /var/log/old_maillog }