Creating the setclock script

The following script is only for real use when your hardware clock (also known as BIOS or CMOS clock) isn't set to GMT time. The recommended setup is setting your hardware clock to GMT and have the time converted to localtime using the /etc/localtime symbolic link. But if you run an OS that doesn't understand a clock set to GMT (most notable are Microsoft OS'es) you might want to set your clock to localtime so that the time is properly displayed on those OS'es. This script will reset the kernel time to the hardware clock without converting the time using the /etc/localtime symlink.

If you want to use this script on your system even if you have your hardware clock set to GMT, then change the UTC variable below to the value of 1.



cat > setclock << "EOF"
#!/bin/sh
# Begin /etc/init.d/setclock

source /etc/init.d/functions
source /etc/sysconfig/clock

CLOCKPARAMS="--hctosys"

case "$UTC" in
        yes|true|1)
                CLOCKPARAMS="$CLOCKPARAMS -u"
                ;;
esac

echo -n "Setting clock..."
/sbin/hwclock $CLOCKPARAMS
evaluate_retval

# End /etc/init.d/setclock
EOF

Creating the /etc/sysconfig/clock file

Create a new file /etc/sysconfig/clock by running the following:



cat > /etc/sysconfig/clock << "EOF"
# Begin /etc/sysconfig/clock

UTC=1

# End /etc/sysconfig/clock
EOF

If your hardware clock (also known as BIOS or CMOS clock) is not set to GMT time, than set the UTC variable in the /etc/sysconfig/clock file to the value 0 (zero).