#!/usr/bin/python

import time

import os



if __name__ == '__main__':

    hwclock_time = " ".join(os.popen("hwclock --show --utc").read().split(" ")[0:6])

    hwclock_timestamp = time.mktime(time.strptime(hwclock_time,'%a %d %b %Y %I:%M:%S %p'))

    os_time = time.time()

    difference = abs(int(hwclock_timestamp)-int(os_time))

    if difference > 60: 

        print 'difference:',difference

        exit(1)

    else:

        print 'time is correct'



注:%I为12小时单位   加了%p 前面得把%H换成%I才可以