I finally decided to deal with the eternal problem in my workplace: the clock runs forward a few minutes. Corporate network - Windows domain, access to the Internet only through a proxy server.
All Windows machines get their time from the domain controller, but I have a Ubuntu workstation due to production needs. I did not find the NTP server in the district. And finally, irritation overpowered laziness and I wrote a script that synchronizes time via http. Of course, if you need time accuracy within a second, then this method will not work for you, but if you are satisfied with an error per second, then it will cope with two tasks.
')
The whole script consists of a pair of lines in python.
from urllib import urlopen import os
proxies = { 'http' : 'http://localhost:3128' } #Request google index page headers = urlopen( 'http://google.com/' , proxies=proxies).info() date = "date -s \"" + headers.getheader( 'Date' ) + "\"" print "Google Date:" + date print os.popen(date).read()
* This source code was highlighted with Source Code Highlighter .
Principle of operation: In the http protocol there is a field which indicates server time. That is, it is enough to select the server that we trust and make any request, get the time value from the headers, and set it as system.
We write the launch schedule in crontab, and set the proxies variable to the address of the corporate proxy, and arrive at the rallies on time :-)
PS: Of course everyone can do it himself in 5 minutes, I am sure there are those who can do it in 5 seconds, but there are also those who are just too lazy :-) this post is for them.