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