Skip to content

Instantly share code, notes, and snippets.

@alexellis
Created February 9, 2018 10:24
Show Gist options
  • Save alexellis/4ce511f08313a16d5a945a5ad27b0f25 to your computer and use it in GitHub Desktop.
Save alexellis/4ce511f08313a16d5a945a5ad27b0f25 to your computer and use it in GitHub Desktop.
Sync time and date via curl
#!/bin/bash
date -d "$(curl -s --head http://google.com | grep ^Date: | sed 's/Date: //g')"
@cnjax
Copy link

cnjax commented Dec 14, 2019

date -s "$(curl -s --head http://google.com | grep ^Date: | sed 's/Date: //g')"
it works.

@alexellis
Copy link
Author

?

@cnjax
Copy link

cnjax commented Dec 15, 2019

I use it to set date time directly.
-s == set
-d == display

Thank you for your script. It help me

@alexellis
Copy link
Author

You're welcome. The original script still works for me on Ubuntu, what OS are you using? Did my original version fail for you?

@cnjax
Copy link

cnjax commented Dec 19, 2019

I am using it on Centos 7. Your script is only show the date time but not set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment