1 00:00:06,450 --> 00:00:10,200 - In this video, I want to explain time in Linux. 2 00:00:10,200 --> 00:00:12,900 It all starts with hardware time. 3 00:00:12,900 --> 00:00:15,630 Hardware time is a time that's kept 4 00:00:15,630 --> 00:00:17,287 in the hardware clock, 5 00:00:17,287 --> 00:00:20,310 that's on the motherboard of your computer. 6 00:00:20,310 --> 00:00:21,870 When your computer is booting, 7 00:00:21,870 --> 00:00:24,723 the only thing that it has is hardware time. 8 00:00:25,650 --> 00:00:28,560 So then you boot your operating system 9 00:00:28,560 --> 00:00:31,290 and your operating system needs system time 10 00:00:31,290 --> 00:00:34,650 and the system time is obtained from the hardware time. 11 00:00:34,650 --> 00:00:37,020 So that means that the hardware time is leading 12 00:00:37,020 --> 00:00:41,370 and it's important that your hardware time is set all right. 13 00:00:41,370 --> 00:00:43,800 Now, how can we manipulate that? 14 00:00:43,800 --> 00:00:45,480 Well, in Linux, we have utilities, 15 00:00:45,480 --> 00:00:46,623 we have hwclock, 16 00:00:47,460 --> 00:00:49,320 hwclock is the utility 17 00:00:49,320 --> 00:00:52,200 that you can use to manipulate the hardware time 18 00:00:52,200 --> 00:00:55,933 and we have utilities like timedatectl, 19 00:00:57,960 --> 00:01:00,233 which is a preferred utility for managing time 20 00:01:00,233 --> 00:01:03,030 in the operating system right now. 21 00:01:03,030 --> 00:01:04,800 if we have timedatectl, 22 00:01:04,800 --> 00:01:07,500 why would you want to manage the hardware time as well? 23 00:01:07,500 --> 00:01:12,210 Well, that is because the timedatectl utility writes here 24 00:01:12,210 --> 00:01:14,970 and if you have a problem or a serious difference 25 00:01:14,970 --> 00:01:17,520 between hardware time and operating system time, 26 00:01:17,520 --> 00:01:18,840 the next time you reboot, 27 00:01:18,840 --> 00:01:22,770 your operating system will have the wrong time available 28 00:01:22,770 --> 00:01:26,610 and that is why hwclock is a very relevant utility. 29 00:01:26,610 --> 00:01:30,630 You can even use hwclock to synchronize the time 30 00:01:30,630 --> 00:01:33,900 between the hardware time and the system time 31 00:01:33,900 --> 00:01:35,910 and that is pretty important 32 00:01:35,910 --> 00:01:38,170 that you are doing that all right 33 00:01:38,170 --> 00:01:41,610 because next, your operating system time 34 00:01:41,610 --> 00:01:46,180 often is synchronizing using NTP, the Network Time Protocol 35 00:01:47,130 --> 00:01:51,210 but NTP is synchronizing with external service 36 00:01:51,210 --> 00:01:54,150 to make sure that you get the time from the internet 37 00:01:54,150 --> 00:01:56,370 and that's only going to work out all right 38 00:01:56,370 --> 00:02:01,370 if the differences falls within a tolerance of 1000 seconds. 39 00:02:02,040 --> 00:02:05,040 So that means that if your operating system clock is off 40 00:02:05,040 --> 00:02:06,840 by more than 1000 seconds, 41 00:02:06,840 --> 00:02:08,850 because a problem in your hardware time, 42 00:02:08,850 --> 00:02:11,460 you won't get any time synchronization 43 00:02:11,460 --> 00:02:14,370 and time is very important for services on Linux 44 00:02:14,370 --> 00:02:16,980 and that is why you better make sure 45 00:02:16,980 --> 00:02:19,593 that it works right before you do anything else.