[673b0d8] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
[b06ca36] | 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
[673b0d8] | 4 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 | ]>
|
---|
[d781ffb] | 7 |
|
---|
[cba2d4e] | 8 | <sect1 id="ch-scripts-clock">
|
---|
| 9 | <?dbhtml filename="clock.html"?>
|
---|
[d781ffb] | 10 |
|
---|
[cba2d4e] | 11 | <title>Configuring the System Clock</title>
|
---|
[d781ffb] | 12 |
|
---|
[cba2d4e] | 13 | <para>Procedures for setting the system clock differ between systemd and
|
---|
| 14 | System V, however the separate procedures do not conflict so both
|
---|
| 15 | procedures should be accomplished to allow switching between systems.</para>
|
---|
| 16 |
|
---|
| 17 | <sect2 id="ch-scripts-setclock">
|
---|
| 18 | <title>System V Clock Configuration</title>
|
---|
| 19 |
|
---|
| 20 | <indexterm zone="ch-scripts-setclock">
|
---|
| 21 | <primary sortas="d-setclock">setclock</primary>
|
---|
| 22 | <secondary>configuring</secondary></indexterm>
|
---|
| 23 |
|
---|
| 24 | <para>The <command>setclock</command> script reads the time from the hardware
|
---|
| 25 | clock, also known as the BIOS or the Complementary Metal Oxide Semiconductor
|
---|
| 26 | (CMOS) clock. If the hardware clock is set to UTC, this script will convert the
|
---|
| 27 | hardware clock's time to the local time using the
|
---|
| 28 | <filename>/etc/localtime</filename> file (which tells the
|
---|
| 29 | <command>hwclock</command> program which timezone the user is in). There is no
|
---|
| 30 | way to detect whether or not the hardware clock is set to UTC, so this
|
---|
| 31 | needs to be configured manually.</para>
|
---|
| 32 |
|
---|
| 33 | <para>The <command>setclock</command> is run via
|
---|
| 34 | <application>udev</application> when the kernel detects the hardware
|
---|
| 35 | capability upon boot. It can also be run manually with the stop parameter to
|
---|
| 36 | store the system time to the CMOS clock.</para>
|
---|
| 37 |
|
---|
| 38 | <para>If you cannot remember whether or not the hardware clock is set to UTC,
|
---|
| 39 | find out by running the <userinput>hwclock --localtime --show</userinput>
|
---|
| 40 | command. This will display what the current time is according to the hardware
|
---|
| 41 | clock. If this time matches whatever your watch says, then the hardware clock is
|
---|
| 42 | set to local time. If the output from <command>hwclock</command> is not local
|
---|
| 43 | time, chances are it is set to UTC time. Verify this by adding or subtracting
|
---|
| 44 | the proper amount of hours for the timezone to the time shown by
|
---|
| 45 | <command>hwclock</command>. For example, if you are currently in the MST
|
---|
| 46 | timezone, which is also known as GMT -0700, add seven hours to the local
|
---|
| 47 | time.</para>
|
---|
| 48 |
|
---|
| 49 | <para>Change the value of the <envar>UTC</envar> variable below
|
---|
| 50 | to a value of <parameter>0</parameter> (zero) if the hardware clock
|
---|
| 51 | is <emphasis>not</emphasis> set to UTC time.</para>
|
---|
[d781ffb] | 52 |
|
---|
[cba2d4e] | 53 | <para>Create a new file <filename>/etc/sysconfig/clock</filename> by running
|
---|
| 54 | the following:</para>
|
---|
[6370fa6] | 55 |
|
---|
[f67f5cf] | 56 | <screen><userinput>cat > /etc/sysconfig/clock << "EOF"
|
---|
[d72e04a] | 57 | <literal># Begin /etc/sysconfig/clock
|
---|
[6370fa6] | 58 |
|
---|
[56cc653] | 59 | UTC=1
|
---|
[6370fa6] | 60 |
|
---|
[2ca8941] | 61 | # Set this to any options you might need to give to hwclock,
|
---|
[63f6e21] | 62 | # such as machine hardware clock type for Alphas.
|
---|
| 63 | CLOCKPARAMS=
|
---|
| 64 |
|
---|
[d72e04a] | 65 | # End /etc/sysconfig/clock</literal>
|
---|
[f67f5cf] | 66 | EOF</userinput></screen>
|
---|
[6370fa6] | 67 |
|
---|
[cba2d4e] | 68 | <para>A good hint explaining how to deal with time on LFS is available
|
---|
| 69 | at <ulink url="&hints-root;time.txt"/>. It explains issues such as
|
---|
| 70 | time zones, UTC, and the <envar>TZ</envar> environment variable.</para>
|
---|
| 71 |
|
---|
| 72 | <note><para>The CLOCKPARAMS and UTC paramaters may be alternatively set
|
---|
| 73 | in the <filename>/etc/sysconfig/rc.site</filename> file.</para></note>
|
---|
| 74 |
|
---|
| 75 | </sect2>
|
---|
| 76 |
|
---|
| 77 | <sect2 id="ch-scripts-systemd-clock">
|
---|
| 78 | <title>Systemd Clock Configuration</title>
|
---|
| 79 |
|
---|
| 80 | <indexterm zone="ch-scripts-clock">
|
---|
| 81 | <primary sortas="d-clock">clock</primary>
|
---|
| 82 | <secondary>configuring</secondary></indexterm>
|
---|
| 83 |
|
---|
| 84 | <para>This section discusses how to configure the
|
---|
| 85 | <command>systemd-timedated</command> system service, which configures
|
---|
| 86 | system clock and timezone.</para>
|
---|
| 87 |
|
---|
| 88 | <para><command>systemd-timedated</command> reads
|
---|
| 89 | <filename>/etc/adjtime</filename>, and depending on the contents of the file,
|
---|
| 90 | it sets the clock to either UTC or local time. Create the
|
---|
| 91 | <filename>/etc/adjtime</filename> file with the following contents <emphasis>if your
|
---|
| 92 | hardware clock is set to local time</emphasis>:</para>
|
---|
| 93 |
|
---|
| 94 | <screen role="nodump"><userinput>cat > /etc/adjtime << "EOF"
|
---|
| 95 | <literal>0.0 0 0.0
|
---|
| 96 | 0
|
---|
| 97 | LOCAL</literal>
|
---|
| 98 | EOF</userinput></screen>
|
---|
| 99 |
|
---|
| 100 | <para>If <filename>/etc/adjtime</filename> isn't present at first boot,
|
---|
| 101 | <command>systemd-timedated</command> will assume that hardware clock is
|
---|
| 102 | set to UTC and create the file using that setting.</para>
|
---|
| 103 |
|
---|
| 104 | <para>You can also use the <command>timedatectl</command> utility to tell
|
---|
| 105 | <command>systemd-timedated</command> if your hardware clock is set to
|
---|
| 106 | UTC or local time:</para>
|
---|
| 107 |
|
---|
| 108 | <screen role="nodump"><userinput>timedatectl set-local-rtc 1</userinput></screen>
|
---|
| 109 |
|
---|
| 110 | <para><command>timedatectl</command> can also be used to change system time and
|
---|
| 111 | time zone.</para>
|
---|
| 112 |
|
---|
| 113 | <para>To change your current system time, issue:</para>
|
---|
| 114 |
|
---|
| 115 | <screen role="nodump"><userinput>timedatectl set-time YYYY:MM:DD HH:MM:SS</userinput></screen>
|
---|
| 116 |
|
---|
| 117 | <para>Hardware clock will also be updated accordingly.</para>
|
---|
| 118 |
|
---|
| 119 | <para>To change your current time zone, issue:</para>
|
---|
| 120 |
|
---|
| 121 | <screen role="nodump"><userinput>timedatectl set-timezone TIMEZONE</userinput></screen>
|
---|
| 122 |
|
---|
| 123 | <para>You can get list of available time zones by running:</para>
|
---|
| 124 |
|
---|
| 125 | <screen role="nodump"><userinput>timedatectl list-timezones</userinput></screen>
|
---|
| 126 |
|
---|
| 127 | <note><para>Please note that <command>timedatectl</command> command can
|
---|
| 128 | be used only on a system booted with Systemd.</para></note>
|
---|
[81fd230] | 129 |
|
---|
[cba2d4e] | 130 | </sect2>
|
---|
[0cda898] | 131 |
|
---|
[6370fa6] | 132 | </sect1>
|
---|