#!/bin/sh RTC_DEVICE="/dev/rtc" if [ ! -e $RTC_DEVICE ]; then echo "FAIL: rtc device does not exist" exit 1 else echo "PASS: rtc device exists" fi /sbin/hwclock -f $RTC_DEVICE if [ $? -ne 0 ]; then echo "FAIL: rtc device open failed" exit 1 else echo "PASS: rtc device open success" fi /sbin/hwclock --systohc if [ $? -ne 0 ]; then echo "FAIL: sync system clock and hardware clock failed" exit 1 else echo "PASS: sync system clock and hardware clock success" fi RTC_TIME=$(/sbin/hwclock -r |awk '{print $4}') echo $RTC_TIME SYS_TIME=$(date +%m/%d/%Y-%X |awk '{print $1}' |awk -F- '{print $2}') echo $SYS_TIME if [ "$RTC_TIME" = "$SYS_TIME" ] ; then echo "PASS: system time same with hardware time" else echo "FAIL: system time different with hardware time" exit 1 fi echo "PASS: rtc test successful" exit 0