[e0508f3c] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?> |
---|
| 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" |
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [ |
---|
| 4 | <!ENTITY % general-entities SYSTEM "../../general.ent"> |
---|
| 5 | %general-entities; |
---|
| 6 | ]> |
---|
| 7 | |
---|
| 8 | <sect1 id="ch-scripts-clock"> |
---|
| 9 | <?dbhtml filename="clock.html"?> |
---|
| 10 | |
---|
| 11 | <title>Configuring the system clock</title> |
---|
| 12 | |
---|
| 13 | <indexterm zone="ch-scripts-clock"> |
---|
| 14 | <primary sortas="d-clock">clock</primary> |
---|
| 15 | <secondary>configuring</secondary></indexterm> |
---|
| 16 | |
---|
| 17 | <para>This section discusses how to configure the |
---|
| 18 | <command>systemd-timedated</command> system service, which configures |
---|
| 19 | system clock and timezone.</para> |
---|
| 20 | |
---|
| 21 | <para>Systemd provides a <command>timedatectl</command> utility which is |
---|
| 22 | used to communicate with <command>systemd-timedated</command>. It can be used |
---|
| 23 | to set the system clock in local time or UTC time, depending on the hardware |
---|
| 24 | clock setting. By default, <command>systemd-timedated</command> will assume |
---|
| 25 | that clock is set to UTC time.</para> |
---|
| 26 | |
---|
| 27 | <para>If you cannot remember whether or not the hardware clock is set to UTC, |
---|
| 28 | find out by running the <userinput>hwclock --localtime --show</userinput> |
---|
| 29 | command. This will display what the current time is according to the hardware |
---|
| 30 | clock. If this time matches whatever your watch says, then the hardware clock is |
---|
| 31 | set to local time. If the output from <command>hwclock</command> is not local |
---|
| 32 | time, chances are it is set to UTC time. Verify this by adding or subtracting |
---|
| 33 | the proper amount of hours for the timezone to the time shown by |
---|
| 34 | <command>hwclock</command>. For example, if you are currently in the MST |
---|
| 35 | timezone, which is also known as GMT -0700, add seven hours to the local |
---|
| 36 | time.</para> |
---|
| 37 | |
---|
[014d534a] | 38 | <para><command>systemd-timedated</command> reads |
---|
| 39 | <filename>/etc/adjtime</filename>, and depending on the contents of the file, |
---|
| 40 | it sets the clock to either UTC or local time.</para> |
---|
| 41 | |
---|
| 42 | <para>Create the <filename>/etc/adjtime</filename> file with the following |
---|
| 43 | contents if your hardware clock is set to local time:</para> |
---|
| 44 | |
---|
| 45 | <screen role="nodump"><userinput>cat > /etc/adjtime << "EOF" |
---|
| 46 | <literal>0.0 0 0.0 |
---|
| 47 | 0 |
---|
| 48 | LOCAL</literal> |
---|
| 49 | EOF</userinput></screen> |
---|
| 50 | |
---|
| 51 | <para>If <filename>/etc/adjtime</filename> isn't present at first boot, |
---|
| 52 | <command>systemd-timedated</command> will assume that hardware clock is |
---|
| 53 | set to UTC and adjust the file according to that.</para> |
---|
| 54 | |
---|
| 55 | <para>If your clock is set to local time, tell |
---|
| 56 | <command>systemd-timedated</command> about it by running the following |
---|
| 57 | command:</para> |
---|
[e0508f3c] | 58 | |
---|
| 59 | <screen role="nodump"><userinput>timedatectl set-local-rtc 1</userinput></screen> |
---|
| 60 | |
---|
| 61 | <para><command>timedatectl</command> can also be used to change system time and |
---|
| 62 | time zone.</para> |
---|
| 63 | |
---|
| 64 | <para>To change your current system time, issue:</para> |
---|
| 65 | |
---|
| 66 | <screen role="nodump"><userinput>timedatectl set-time YYYY:MM:DD HH:MM:SS</userinput></screen> |
---|
| 67 | |
---|
| 68 | <para>Hardware clock will also be updated accordingly.</para> |
---|
| 69 | |
---|
| 70 | <para>To change your current time zone, issue:</para> |
---|
| 71 | |
---|
| 72 | <screen role="nodump"><userinput>timedatectl set-timezone TIMEZONE</userinput></screen> |
---|
| 73 | |
---|
| 74 | <para>You can get list of available time zones by running:</para> |
---|
| 75 | |
---|
| 76 | <screen role="nodump"><userinput>timedatectl list-timezones</userinput></screen> |
---|
| 77 | |
---|
| 78 | <note><para>Please note that <command>timedatectl</command> command can |
---|
[0131d1b] | 79 | be used only on a system booted with systemd.</para></note> |
---|
[e0508f3c] | 80 | |
---|
| 81 | </sect1> |
---|