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,980 On newer systems, that might be by systemd timers. 14 00:00:53,980 --> 00:01:00,779 And it works with etc.logrotate.conf and the drop-in directory logrotate.d. 15 00:01:00,779 --> 00:01:05,540 These are the configuration files that determine which files to monitor and what should happen 16 00:01:05,540 --> 00:01:08,400 in specific conditions. 17 00:01:08,400 --> 00:01:11,540 In these conditions, different criteria can be used. 18 00:01:11,540 --> 00:01:14,300 And that includes ages or sizes. 19 00:01:14,300 --> 00:01:15,500 Let me show you. 20 00:01:15,500 --> 00:01:20,139 So the main file in log rotate is logrotate.conf. 21 00:01:20,139 --> 00:01:23,540 In logrotate.conf, you set the standards. 22 00:01:23,540 --> 00:01:27,099 You can include files in logrotate.d as well. 23 00:01:27,099 --> 00:01:31,239 And if you want to keep the standards, there's no reason to redefine. 24 00:01:31,239 --> 00:01:33,820 They will be inherited from this file. 25 00:01:33,820 --> 00:01:35,300 So the default is weekly. 26 00:01:35,300 --> 00:01:38,300 Every week, a file will be rotated. 27 00:01:38,300 --> 00:01:42,980 And rotate four means that we keep the four last weeks. 28 00:01:42,980 --> 00:01:45,379 And we create a new one by using create. 29 00:01:45,379 --> 00:01:47,779 These are the most important ones. 30 00:01:47,779 --> 00:01:50,519 But you need to realize one thing. 31 00:01:50,519 --> 00:01:54,639 The result of this configuration is that you will have your current log file. 32 00:01:54,639 --> 00:01:59,279 And the log file for the last four weeks, with everything before that, will automatically 33 00:01:59,279 --> 00:02:02,059 be rotated away. 34 00:02:02,059 --> 00:02:04,040 And that's something to consider. 35 00:02:04,040 --> 00:02:09,119 Because what is going on if you want to analyze what happened on your system six weeks ago? 36 00:02:09,119 --> 00:02:10,119 Well, simple. 37 00:02:10,119 --> 00:02:12,880 Then you don't have the log information anymore. 38 00:02:12,880 --> 00:02:19,679 And if you haven't created your backup for these log files, then they will be gone forever. 39 00:02:19,720 --> 00:02:21,320 There's 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.