source: chapter07/setclock.xml@ cba2d4e

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
Last change on this file since cba2d4e was cba2d4e, checked in by Bruce Dubbs <bdubbs@…>, 10 years ago

Added systemd and dbus to the book.
Set up systemd and System V side-by-side with the
ability to reboot to either system.

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@10520 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 5.4 KB
Line 
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 <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>
52
53 <para>Create a new file <filename>/etc/sysconfig/clock</filename> by running
54 the following:</para>
55
56<screen><userinput>cat &gt; /etc/sysconfig/clock &lt;&lt; "EOF"
57<literal># Begin /etc/sysconfig/clock
58
59UTC=1
60
61# Set this to any options you might need to give to hwclock,
62# such as machine hardware clock type for Alphas.
63CLOCKPARAMS=
64
65# End /etc/sysconfig/clock</literal>
66EOF</userinput></screen>
67
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 &gt; /etc/adjtime &lt;&lt; "EOF"
95<literal>0.0 0 0.0
960
97LOCAL</literal>
98EOF</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>
131
132</sect1>
Note: See TracBrowser for help on using the repository browser.