# set_system_clock_from_google.sh Sets system time based on what is reported by google.com. Useful for cases where it is not possible to use the standard `ntpdate` command. For eample, if a Linux machine is on a network which is only able to reach the internet through an HTTP proxy. Inspired by ryenus' answer @ https://superuser.com/a/807326/72342 ## Installation ```bash # Download latest set_system_clock_from_google.sh script. curl -sS --remote-name-all $( \ curl -sS https://api.github.com/gists/60c8a4e22431c4271200cab68186deb7 \ | jq -r '.files[].raw_url' \ | grep -v '\/\._' \ ) # Set permissions and move to local sbin. chmod a+x set_system_clock_from_google.sh sudo chown root:root set_system_clock_from_google.sh sudo mv set_system_clock_from_google.sh /usr/local/sbin/ ``` ## Cronjob Scheduling Here is a command to install a cronjob which syncs the system clock at the top of every hour: ```bash (sudo crontab -l 2>/dev/null; echo '1 * * * * /usr/local/sbin/set_system_clock_from_google.sh') \ | sudo crontab - ``` ### Verify installation List all root cronjobs and verify the job has been added: ```bash sudo crontab -l ``` ### Example output ``` 1 * * * * /usr/local/sbin/set_system_clock_from_google.sh ``` ## Run or test it manually Verbose output is available when the `-v` flag is passed. ```bash /usr/local/sbin/set_system_clock_from_google.sh -v ```