Set the hardware clock in Python?

Diego Sueiro picture Diego Sueiro · Feb 3, 2010 · Viewed 19.2k times · Source

How do I set the hardware clock with Python on embedded Linux systems?

Answer

zdav picture zdav · Feb 3, 2010

Probably no easy way other than doing an os.system() call.

import os
os.system('hwclock --set %s' % date_str)

or using the 'date' command

import os
os.system('date -s %s' % date_str)

or if you are dying to do some c coding, wrapping the system calls with swig... but I think that would be more work than its worth.