| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 | <sect1 id="ch07-setclock"><title>Creating the setclock script</title><?dbhtml filename="setclock.html" dir="chapter07"?><para>The following script is only for real use when the hardware clock (alsoknown as BIOS or CMOS clock) isn't set to GMT time. The recommendedsetup is setting the hardware clock to GMT and having the time convertedto localtime using the /etc/localtime symbolic link. But if anOS is run that doesn't understand a clock set to GMT (most notable areMicrosoft OS'es) you may want to set the clock to localtime so thatthe time is properly displayed on those OS'es. This script will then set the kernel time to the hardware clock without converting the time usingthe /etc/localtime symlink.</para><para>Create the <filename>/etc/init.d/setclock</filename> script by runningthe following command:</para><para><screen><userinput>cat > /etc/init.d/setclock << "EOF"</userinput>#!/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/functionssource /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)                CLOCKPARAMS="$CLOCKPARAMS --utc"                ;;        no|false|0)                CLOCKPARAMS="$CLOCKPARAMS --localtime"                ;;esacecho -n "Setting clock..."/sbin/hwclock $CLOCKPARAMSevaluate_retval# End /etc/init.d/setclock<userinput>EOF</userinput></screen></para><sect2><title>Creating the /etc/sysconfig/clock file</title><para>If you want to use this script on your system even if thehardware clock is set to GMT, then the UTC variable below has to bechanged to the value of <emphasis>1</emphasis>.</para><para>Create a new file <filename>/etc/sysconfig/clock</filename> by runningthe following:</para><para><screen><userinput>cat > /etc/sysconfig/clock << "EOF"</userinput># Begin /etc/sysconfig/clockUTC=0# End /etc/sysconfig/clock<userinput>EOF</userinput></screen></para><para>Now, you may want to take a look at a very good hint explaining how wedeal with time on LFS at <ulink url="&hints-root;time.txt">&hints-root;time.txt</ulink>. It explains issues such as timezones, UTC, and the TZ environment variable.</para></sect2></sect1>
 |