2001-01-24 00:31:17 +00:00
|
|
|
<sect1 id="ch07-setclock">
|
|
|
|
<title>Creating the setclock script</title>
|
2001-09-26 01:35:10 +01:00
|
|
|
<?dbhtml filename="setclock.html" dir="chapter07"?>
|
|
|
|
|
2001-01-24 00:31:17 +00:00
|
|
|
|
2001-07-22 20:45:10 +01:00
|
|
|
<para>The following script is only for real use when the hardware clock (also
|
2001-01-24 00:31:17 +00:00
|
|
|
known as BIOS or CMOS clock) isn't set to GMT time. The recommended
|
2001-03-19 14:30:14 +00:00
|
|
|
setup is setting the hardware clock to GMT and having the time converted
|
|
|
|
to localtime using the /etc/localtime symbolic link. But if an
|
|
|
|
OS is run that doesn't understand a clock set to GMT (most notable are
|
2001-08-29 20:50:53 +01:00
|
|
|
Microsoft OS'es) you may want to set the clock to localtime so that
|
|
|
|
the time is properly displayed on those OS'es. This script will then
|
|
|
|
set the kernel time to the hardware clock without converting the time using
|
2001-07-22 20:45:10 +01:00
|
|
|
the /etc/localtime symlink.</para>
|
2001-01-24 00:31:17 +00:00
|
|
|
|
2001-07-22 20:45:10 +01:00
|
|
|
<para>Create the <filename>/etc/init.d/setclock</filename> script by running
|
|
|
|
the following command:</para>
|
2001-01-24 00:31:17 +00:00
|
|
|
|
2001-08-09 17:43:10 +01:00
|
|
|
<para><screen><userinput>cat > /etc/init.d/setclock << "EOF"</userinput>
|
2001-01-24 00:31:17 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# Begin /etc/init.d/setclock
|
|
|
|
|
|
|
|
#
|
|
|
|
# Include the functions declared in the /etc/init.d/functions file
|
|
|
|
# and include the variables from the /etc/sysconfig/clock file
|
|
|
|
#
|
|
|
|
|
|
|
|
source /etc/init.d/functions
|
|
|
|
source /etc/sysconfig/clock
|
|
|
|
|
|
|
|
#
|
|
|
|
# Right now we want to set the kernel clock according to the hardware
|
|
|
|
# clock, so we use the -hctosys parameter.
|
|
|
|
#
|
|
|
|
|
|
|
|
CLOCKPARAMS="--hctosys"
|
|
|
|
|
|
|
|
#
|
|
|
|
# If the UTC variable is set in the /etc/sysconfig/clock file, add the
|
|
|
|
# -u parameter as well which tells hwclock that the hardware clock is
|
|
|
|
# set to UTC time instead of local time.
|
|
|
|
#
|
|
|
|
|
|
|
|
case "$UTC" in
|
|
|
|
yes|true|1)
|
2001-04-17 02:40:48 +01:00
|
|
|
CLOCKPARAMS="$CLOCKPARAMS --utc"
|
|
|
|
;;
|
|
|
|
no|false|0)
|
|
|
|
CLOCKPARAMS="$CLOCKPARAMS --localtime"
|
2001-01-24 00:31:17 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
echo -n "Setting clock..."
|
|
|
|
/sbin/hwclock $CLOCKPARAMS
|
|
|
|
evaluate_retval
|
|
|
|
|
|
|
|
# End /etc/init.d/setclock
|
2001-07-22 20:45:10 +01:00
|
|
|
<userinput>EOF</userinput></screen></para>
|
2001-01-24 00:31:17 +00:00
|
|
|
|
|
|
|
<sect2>
|
|
|
|
<title>Creating the /etc/sysconfig/clock file</title>
|
|
|
|
|
2001-08-29 20:50:53 +01:00
|
|
|
<para>If you want to use this script on your system even if the
|
|
|
|
hardware clock is set to GMT, then the UTC variable below has to be
|
|
|
|
changed to the value of <emphasis>1</emphasis>.</para>
|
|
|
|
|
2001-07-22 20:45:10 +01:00
|
|
|
<para>Create a new file <filename>/etc/sysconfig/clock</filename> by running
|
|
|
|
the following:</para>
|
2001-01-24 00:31:17 +00:00
|
|
|
|
2001-07-22 20:45:10 +01:00
|
|
|
<para><screen><userinput>cat > /etc/sysconfig/clock << "EOF"</userinput>
|
2001-01-24 00:31:17 +00:00
|
|
|
# Begin /etc/sysconfig/clock
|
|
|
|
|
2001-08-29 20:50:53 +01:00
|
|
|
UTC=0
|
2001-01-24 00:31:17 +00:00
|
|
|
|
|
|
|
# End /etc/sysconfig/clock
|
2001-07-22 20:45:10 +01:00
|
|
|
<userinput>EOF</userinput></screen></para>
|
2001-01-24 00:31:17 +00:00
|
|
|
|
2001-07-22 20:45:10 +01:00
|
|
|
<para>Now, you may want to take a look at a very good hint explaining how we
|
|
|
|
deal with time on LFS at <ulink
|
2001-09-07 23:20:09 +01:00
|
|
|
url="&hints-root;time.txt">&hints-root;time.txt</ulink>.
|
2001-07-22 20:45:10 +01:00
|
|
|
It explains issues such as timezones, UTC, and the TZ
|
|
|
|
environment variable.</para>
|
2001-04-21 17:47:37 +01:00
|
|
|
|
2001-01-24 00:31:17 +00:00
|
|
|
</sect2>
|
|
|
|
|
|
|
|
</sect1>
|
|
|
|
|