1
00:00:00,000 --> 00:00:09,880
In this video, we'll talk about log rotate.

2
00:00:09,880 --> 00:00:11,800
So why do we need log rotate?

3
00:00:11,800 --> 00:00:13,040
Well, simple.

4
00:00:13,040 --> 00:00:18,680
If you are logging to files, that is something that can go beyond control.

5
00:00:18,680 --> 00:00:24,120
If some service is getting crazy, it might be logging large amounts of data very frequently.

6
00:00:24,120 --> 00:00:27,760
And that means that your log files will keep on growing and growing.

7
00:00:27,760 --> 00:00:30,940
And in the end, you will run out of disk space.

8
00:00:30,940 --> 00:00:33,040
That is why we need log rotate.

9
00:00:33,040 --> 00:00:37,639
Log rotate ensures that log files won't grow too big.

10
00:00:37,639 --> 00:00:44,959
And because R6.logd doesn't limit log files in any way by size, this is an important addition.

11
00:00:44,959 --> 00:00:47,959
Log rotate is started as a scheduled job.

12
00:00:47,959 --> 00:00:50,560
So on older systems, that might be through Chrome.

13
00:00:50,560 --> 00:00:53,959
On newer systems, that might be by systemd timers.

14
00:00:53,959 --> 00:01:00,759
And it works with etc.logrotate.conf and the drop-in directory logrotate.d.

15
00:01:00,759 --> 00:01:05,519
These are the configuration files that determine which files to monitor and what should happen

16
00:01:05,519 --> 00:01:08,360
in specific conditions.

17
00:01:08,360 --> 00:01:11,519
In these conditions, different criteria can be used.

18
00:01:11,519 --> 00:01:14,279
And that includes ages or sizes.

19
00:01:14,279 --> 00:01:15,279
Let me show you.

20
00:01:15,279 --> 00:01:20,080
So the main file in log rotate is logrotate.conf.

21
00:01:20,080 --> 00:01:23,519
In logrotate.conf, you set the standards.

22
00:01:23,519 --> 00:01:27,040
You can include files in logrotate.d as well.

23
00:01:27,040 --> 00:01:31,199
And if you want to keep the standards, there's no reason to redefine.

24
00:01:31,199 --> 00:01:33,800
They will be inherited from this file.

25
00:01:33,800 --> 00:01:35,279
So the default is weekly.

26
00:01:35,279 --> 00:01:38,279
Every week, a file will be rotated.

27
00:01:38,279 --> 00:01:42,959
And rotate four means that we keep the four last weeks.

28
00:01:42,959 --> 00:01:45,360
And we create a new one by using create.

29
00:01:45,360 --> 00:01:47,760
These are the most important ones.

30
00:01:47,760 --> 00:01:50,480
But you need to realize one thing.

31
00:01:50,480 --> 00:01:54,680
The result of this configuration is that you will have your current log file and the

32
00:01:54,680 --> 00:02:00,400
log file for the last four weeks, with everything before that, will automatically be rotated

33
00:02:00,400 --> 00:02:02,000
away.

34
00:02:02,000 --> 00:02:04,000
And that's something to consider.

35
00:02:04,000 --> 00:02:09,080
Because what is going on if you want to analyze what happened on your system six weeks ago?

36
00:02:09,080 --> 00:02:10,080
Well, simple.

37
00:02:10,080 --> 00:02:12,839
Then you don't have the log information anymore.

38
00:02:12,839 --> 00:02:19,639
And if you haven't created your backup for these log files, then they will be gone forever.

39
00:02:19,639 --> 00:02:21,320
And no way to get them back.

40
00:02:21,320 --> 00:02:25,520
So logrotate is awesome, but there's a couple of things to be aware of anyway.

