Created
March 27, 2022 14:38
-
-
Save ahmetozer/1fdc2ba98e17a26ae7122216c0550661 to your computer and use it in GitHub Desktop.
Update date and time with curl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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