Python equivalent of settimeofday()?
Peter Hansen
peter at engcorp.com
Fri Jan 9 09:23:55 EST 2004
"Narendra C. Tulpule" wrote:
>
> do you know how (or if) I can set time on a system using Python?
> i.e. is there an equivalent of the shell's 'date -s' or the system
> call settimeofday()?
Maybe some variation on this?
import os,time
def settimeofday(tt):
ts = time.ctime(tt)
os.system("/sbin/hwclock --set '--date=%s'"% ts)
os.system("/sbin/hwclock --hctosys")
??
Note the final line, which retrieves the time from the hardware so the
system clock is also updated.
-Peter
More information about the Python-list
mailing list