Skip to content

Instantly share code, notes, and snippets.

@alexellis
Created February 9, 2018 10:24
Show Gist options
  • Select an option

  • Save alexellis/4ce511f08313a16d5a945a5ad27b0f25 to your computer and use it in GitHub Desktop.

Select an option

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

cnjax commented Dec 14, 2019

Copy link
Copy Markdown

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

@alexellis

Copy link
Copy Markdown
Author

?

@cnjax

cnjax commented Dec 15, 2019

Copy link
Copy Markdown

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

Thank you for your script. It help me

@alexellis

Copy link
Copy Markdown
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

cnjax commented Dec 19, 2019

Copy link
Copy Markdown

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