setclock.xml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. <sect1 id="ch-scripts-clock">
  8. <?dbhtml filename="clock.html"?>
  9. <title>Configuring the System Clock</title>
  10. <para>Procedures for setting the system clock differ between systemd and
  11. System V, however the separate procedures do not conflict so both
  12. procedures should be accomplished to allow switching between systems.</para>
  13. <sect2 id="ch-scripts-setclock">
  14. <title>System V Clock Configuration</title>
  15. <indexterm zone="ch-scripts-setclock">
  16. <primary sortas="d-setclock">setclock</primary>
  17. <secondary>configuring</secondary></indexterm>
  18. <para>The <command>setclock</command> script reads the time from the hardware
  19. clock, also known as the BIOS or the Complementary Metal Oxide Semiconductor
  20. (CMOS) clock. If the hardware clock is set to UTC, this script will convert the
  21. hardware clock's time to the local time using the
  22. <filename>/etc/localtime</filename> file (which tells the
  23. <command>hwclock</command> program which timezone the user is in). There is no
  24. way to detect whether or not the hardware clock is set to UTC, so this
  25. needs to be configured manually.</para>
  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>
  30. <para>If you cannot remember whether or not the hardware clock is set to UTC,
  31. find out by running the <userinput>hwclock --localtime --show</userinput>
  32. command. This will display what the current time is according to the hardware
  33. clock. If this time matches whatever your watch says, then the hardware clock is
  34. set to local time. If the output from <command>hwclock</command> is not local
  35. time, chances are it is set to UTC time. Verify this by adding or subtracting
  36. the proper amount of hours for the timezone to the time shown by
  37. <command>hwclock</command>. For example, if you are currently in the MST
  38. timezone, which is also known as GMT -0700, add seven hours to the local
  39. time.</para>
  40. <para>Change the value of the <envar>UTC</envar> variable below
  41. to a value of <parameter>0</parameter> (zero) if the hardware clock
  42. is <emphasis>not</emphasis> set to UTC time.</para>
  43. <para>Create a new file <filename>/etc/sysconfig/clock</filename> by running
  44. the following:</para>
  45. <screen><userinput>cat &gt; /etc/sysconfig/clock &lt;&lt; "EOF"
  46. <literal># Begin /etc/sysconfig/clock
  47. UTC=1
  48. # Set this to any options you might need to give to hwclock,
  49. # such as machine hardware clock type for Alphas.
  50. CLOCKPARAMS=
  51. # End /etc/sysconfig/clock</literal>
  52. EOF</userinput></screen>
  53. <para>A good hint explaining how to deal with time on LFS is available
  54. at <ulink url="&hints-root;time.txt"/>. It explains issues such as
  55. time zones, UTC, and the <envar>TZ</envar> environment variable.</para>
  56. <note><para>The CLOCKPARAMS and UTC paramaters may be alternatively set
  57. in the <filename>/etc/sysconfig/rc.site</filename> file.</para></note>
  58. </sect2>
  59. <sect2 id="ch-scripts-systemd-clock">
  60. <title>Systemd Clock Configuration</title>
  61. <indexterm zone="ch-scripts-clock">
  62. <primary sortas="d-clock">clock</primary>
  63. <secondary>configuring</secondary></indexterm>
  64. <para>This section discusses how to configure the
  65. <command>systemd-timedated</command> system service, which configures
  66. system clock and timezone.</para>
  67. <para><command>systemd-timedated</command> reads
  68. <filename>/etc/adjtime</filename>, and depending on the contents of the file,
  69. it sets the clock to either UTC or local time. Create the
  70. <filename>/etc/adjtime</filename> file with the following contents <emphasis>if your
  71. hardware clock is set to local time</emphasis>:</para>
  72. <screen role="nodump"><userinput>cat &gt; /etc/adjtime &lt;&lt; "EOF"
  73. <literal>0.0 0 0.0
  74. 0
  75. LOCAL</literal>
  76. EOF</userinput></screen>
  77. <para>If <filename>/etc/adjtime</filename> isn't present at first boot,
  78. <command>systemd-timedated</command> will assume that hardware clock is
  79. set to UTC and create the file using that setting.</para>
  80. <para>You can also use the <command>timedatectl</command> utility to tell
  81. <command>systemd-timedated</command> if your hardware clock is set to
  82. UTC or local time:</para>
  83. <screen role="nodump"><userinput>timedatectl set-local-rtc 1</userinput></screen>
  84. <para><command>timedatectl</command> can also be used to change system time and
  85. time zone.</para>
  86. <para>To change your current system time, issue:</para>
  87. <screen role="nodump"><userinput>timedatectl set-time YYYY:MM:DD HH:MM:SS</userinput></screen>
  88. <para>Hardware clock will also be updated accordingly.</para>
  89. <para>To change your current time zone, issue:</para>
  90. <screen role="nodump"><userinput>timedatectl set-timezone TIMEZONE</userinput></screen>
  91. <para>You can get list of available time zones by running:</para>
  92. <screen role="nodump"><userinput>timedatectl list-timezones</userinput></screen>
  93. <note><para>Please note that <command>timedatectl</command> command can
  94. be used only on a system booted with Systemd.</para></note>
  95. </sect2>
  96. </sect1>