In this video, we'll talk about log rotate.
So why do we need log rotate?
Well, simple.
If you are logging to files, that is something that can go beyond control.
If some service is getting crazy, it might be logging large amounts of data very frequently.
And that means that your log files will keep on growing and growing.
And in the end, you will run out of disk space.
That is why we need log rotate.
Log rotate ensures that log files won't grow too big.
And because R6.logd doesn't limit log files in any way by size, this is an important addition.
Log rotate is started as a scheduled job.
So on older systems, that might be through Chrome.
On newer systems, that might be by systemd timers.
And it works with etc.logrotate.conf and the drop-in directory logrotate.d.
These are the configuration files that determine which files to monitor and what should happen
in specific conditions.
In these conditions, different criteria can be used.
And that includes ages or sizes.
Let me show you.
So the main file in log rotate is logrotate.conf.
In logrotate.conf, you set the standards.
You can include files in logrotate.d as well.
And if you want to keep the standards, there's no reason to redefine.
They will be inherited from this file.
So the default is weekly.
Every week, a file will be rotated.
And rotate four means that we keep the four last weeks.
And we create a new one by using create.
These are the most important ones.
But you need to realize one thing.
The result of this configuration is that you will have your current log file and the
log file for the last four weeks, with everything before that, will automatically be rotated
away.
And that's something to consider.
Because what is going on if you want to analyze what happened on your system six weeks ago?
Well, simple.
Then you don't have the log information anymore.
And if you haven't created your backup for these log files, then they will be gone forever.
And no way to get them back.
So logrotate is awesome, but there's a couple of things to be aware of anyway.