| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 | <sect1 id="ch07-setclock"><title>Creating the setclock script</title><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) a user might want to set the clock to localtime so thatthe time is properly displayed on those OS'es. This script will resetthe kernel time to the hardware clock without converting the time usingthe /etc/localtime symlink.</para><para>If a user wants to use this script on the system even if the hardware clock is set to GMT, then the UTC variable below has to be changed to thevalue of <emphasis>1</emphasis>.</para><literallayout><userinput>cat > 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 -u"                ;;esacecho -n "Setting clock..."/sbin/hwclock $CLOCKPARAMSevaluate_retval# End /etc/init.d/setclock<userinput>EOF</userinput></literallayout><sect2><title>Creating the /etc/sysconfig/clock file</title><para>Create a new file <filename>/etc/sysconfig/clock</filename> by runningthe following:</para><literallayout><userinput>cat > /etc/sysconfig/clock << "EOF"</userinput># Begin /etc/sysconfig/clockUTC=1# End /etc/sysconfig/clock<userinput>EOF</userinput></literallayout><para>If the hardware clock (also known as BIOS or CMOS clock) is not set toGMT time, then the UTC variable in the /etc/sysconfig/clock file needs to be set tothe value <emphasis>0</emphasis> (zero).</para></sect2></sect1>
 |