#!/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‘
原文地址:http://4249964.blog.51cto.com/4239964/1536498