Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set the hardware clock in Python?

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

like image 752
Diego Sueiro Avatar asked Feb 03 '10 17:02

Diego Sueiro


1 Answers

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.

like image 155
zdav Avatar answered Oct 03 '22 18:10

zdav