Skip to content

Instantly share code, notes, and snippets.

@ahmetozer
Created March 27, 2022 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmetozer/1fdc2ba98e17a26ae7122216c0550661 to your computer and use it in GitHub Desktop.
Save ahmetozer/1fdc2ba98e17a26ae7122216c0550661 to your computer and use it in GitHub Desktop.
Update date and time with curl
#!/bin/sh
function updateDate {
date -s"@$(curl ahmetozer.org/cdn-cgi/tracert -s | grep ts= | cut -d"=" -f2 | cut -d"." -f1)"
if [ "$?" == "0" ]
then
updated="true"
fi
}
if [ "$1" == "service" ] || [ "true" == "$service" ]
then
while true
do
updateDate
if [ "$updated" == "true" ]
then
sleep 600
else
sleep 30
fi
done
else
updateDate
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment