setclock.xml 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <sect1 id="ch07-setclock">
  2. <title>Creating the setclock script</title>
  3. <para>
  4. The following script is only for real use when your hardware clock (also
  5. known as BIOS or CMOS clock) isn't set to GMT time. The recommended
  6. setup is setting your hardware clock to GMT and have the time converted
  7. to localtime using the /etc/localtime symbolic link. But if you run an
  8. OS that doesn't understand a clock set to GMT (most notable are
  9. Microsoft OS'es) you might want to set your clock to localtime so that
  10. the time is properly displayed on those OS'es. This script will reset
  11. the kernel time to the hardware clock without converting the time using
  12. the /etc/localtime symlink.
  13. </para>
  14. <para>
  15. If you want to use this script on your system even if you have your
  16. hardware clock set to GMT, then change the UTC variable below to the
  17. value of <emphasis>1</emphasis>.
  18. </para>
  19. <literallayout>
  20. <userinput>cat &gt; setclock &lt;&lt; "EOF"</userinput>
  21. #!/bin/sh
  22. # Begin /etc/init.d/setclock
  23. #
  24. # Include the functions declared in the /etc/init.d/functions file
  25. # and include the variables from the /etc/sysconfig/clock file
  26. #
  27. source /etc/init.d/functions
  28. source /etc/sysconfig/clock
  29. #
  30. # Right now we want to set the kernel clock according to the hardware
  31. # clock, so we use the -hctosys parameter.
  32. #
  33. CLOCKPARAMS="--hctosys"
  34. #
  35. # If the UTC variable is set in the /etc/sysconfig/clock file, add the
  36. # -u parameter as well which tells hwclock that the hardware clock is
  37. # set to UTC time instead of local time.
  38. #
  39. case "$UTC" in
  40. yes|true|1)
  41. CLOCKPARAMS="$CLOCKPARAMS -u"
  42. ;;
  43. esac
  44. echo -n "Setting clock..."
  45. /sbin/hwclock $CLOCKPARAMS
  46. evaluate_retval
  47. # End /etc/init.d/setclock
  48. <userinput>EOF</userinput>
  49. </literallayout>
  50. <sect2>
  51. <title>Creating the /etc/sysconfig/clock file</title>
  52. <para>
  53. Create a new file <filename>/etc/sysconfig/clock</filename> by running
  54. the following:
  55. </para>
  56. <literallayout>
  57. <userinput>cat &gt; /etc/sysconfig/clock &lt;&lt; "EOF"</userinput>
  58. # Begin /etc/sysconfig/clock
  59. UTC=1
  60. # End /etc/sysconfig/clock
  61. <userinput>EOF</userinput>
  62. </literallayout>
  63. <para>
  64. If your hardware clock (also known as BIOS or CMOS clock) is not set to
  65. GMT time, than set the UTC variable in the /etc/sysconfig/clock file to
  66. the value <emphasis>0</emphasis> (zero).
  67. </para>
  68. </sect2>
  69. </sect1>