An easy way to get the right time in Python

advertisements

I'm running some jobs on a cluster where the dates on each node are slightly off from one another. Is there an easy way to get the time from somewhere on the internet via python or do I need to have the sysadmin sync the times between the machines more frequently?

I'd like to put a time-stamp in the output from each job I launch, but obviously the accuracy of the python's time.strftime() etc are going to depend on the machine knowing the correct time. I'd love accuracy within a few seconds, but right now it's within minutes.


Try ntplib for python. I've played around with it a bit and it seems pretty stable.

https://pypi.python.org/pypi/ntplib/