Changeset cba2d4e for chapter07/setclock.xml
- Timestamp:
- 04/03/2014 09:52:09 PM (10 years ago)
- Branches:
- 10.0, 10.0-rc1, 10.1, 10.1-rc1, 11.0, 11.0-rc1, 11.0-rc2, 11.0-rc3, 11.1, 11.1-rc1, 11.2, 11.2-rc1, 11.3, 11.3-rc1, 12.0, 12.0-rc1, 12.1, 12.1-rc1, 7.6, 7.7, 7.8, 7.9, 8.0, 8.1, 8.2, 8.3, 8.4, 9.0, 9.1, arm, bdubbs/gcc13, ml-11.0, multilib, renodr/libudev-from-systemd, s6-init, trunk, xry111/arm64, xry111/arm64-12.0, xry111/clfs-ng, xry111/lfs-next, xry111/loongarch, xry111/loongarch-12.0, xry111/loongarch-12.1, xry111/mips64el, xry111/pip3, xry111/rust-wip-20221008, xry111/update-glibc
- Children:
- 9839808
- Parents:
- 008436e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
chapter07/setclock.xml
r008436e rcba2d4e 6 6 ]> 7 7 8 <sect1 id="ch-scripts- setclock">9 <?dbhtml filename=" setclock.html"?>8 <sect1 id="ch-scripts-clock"> 9 <?dbhtml filename="clock.html"?> 10 10 11 <title>Configuring the setclock Script</title>11 <title>Configuring the System Clock</title> 12 12 13 < indexterm zone="ch-scripts-setclock">14 <primary sortas="d-setclock">setclock</primary>15 <secondary>configuring</secondary></indexterm>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 16 17 <para>The <command>setclock</command> script reads the time from the hardware 18 clock, also known as the BIOS or the Complementary Metal Oxide Semiconductor 19 (CMOS) clock. If the hardware clock is set to UTC, this script will convert the 20 hardware clock's time to the local time using the 21 <filename>/etc/localtime</filename> file (which tells the 22 <command>hwclock</command> program which timezone the user is in). There is no 23 way to detect whether or not the hardware clock is set to UTC, so this 24 needs to be configured manually.</para> 17 <sect2 id="ch-scripts-setclock"> 18 <title>System V Clock Configuration</title> 25 19 26 <para>The <command>setclock</command> is run via 27 <application>udev</application> when the kernel detects the hardware 28 capability upon boot. It can also be run manually with the stop parameter to 29 store the system time to the CMOS clock.</para> 20 <indexterm zone="ch-scripts-setclock"> 21 <primary sortas="d-setclock">setclock</primary> 22 <secondary>configuring</secondary></indexterm> 30 23 31 <para>If you cannot remember whether or not the hardware clock is set to UTC, 32 find out by running the <userinput>hwclock --localtime --show</userinput> 33 command. This will display what the current time is according to the hardware 34 clock. If this time matches whatever your watch says, then the hardware clock is 35 set to local time. If the output from <command>hwclock</command> is not local 36 time, chances are it is set to UTC time. Verify this by adding or subtracting 37 the proper amount of hours for the timezone to the time shown by 38 <command>hwclock</command>. For example, if you are currently in the MST 39 timezone, which is also known as GMT -0700, add seven hours to the local 40 time.</para> 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> 41 32 42 <para>Change the value of the <envar>UTC</envar> variable below 43 to a value of <parameter>0</parameter> (zero) if the hardware clock 44 is <emphasis>not</emphasis> set to UTC time.</para> 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> 45 37 46 <para>Create a new file <filename>/etc/sysconfig/clock</filename> by running 47 the following:</para> 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> 52 53 <para>Create a new file <filename>/etc/sysconfig/clock</filename> by running 54 the following:</para> 48 55 49 56 <screen><userinput>cat > /etc/sysconfig/clock << "EOF" … … 59 66 EOF</userinput></screen> 60 67 61 <para>A good hint explaining how to deal with time on LFS is available62 at <ulink url="&hints-root;time.txt"/>. It explains issues such as63 time zones, UTC, and the <envar>TZ</envar> environment variable.</para>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> 64 71 65 <note><para>The CLOCKPARAMS and UTC paramaters may be alternatively set 66 in the <filename>/etc/sysconfig/rc.site</filename> file.</para></note> 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> 129 130 </sect2> 67 131 68 132 </sect1>
Note:
See TracChangeset
for help on using the changeset viewer.