Created
June 23, 2025 03:34
-
-
Save x00real/fb7c7ac6e22b924e3c1d58fae75fc3af to your computer and use it in GitHub Desktop.
This file contains hidden or 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/bash | |
# Automatically Updates System Time According to the NIST Atomic Clock in a Linux Environment | |
nistTime=$(curl -I --insecure 'https://nist.time.gov/' | grep "Date") | |
echo $nistTime | |
dateString=$(echo $nistTime | cut -d' ' -f2-7) | |
dayString=$(echo $nistTime | cut -d' ' -f2-2) | |
dateValue=$(echo $nistTime | cut -d' ' -f3-3) | |
monthValue=$(echo $nistTime | cut -d' ' -f4-4) | |
yearValue=$(echo $nistTime | cut -d' ' -f5-5) | |
timeValue=$(echo $nistTime | cut -d' ' -f6-6) | |
timeZoneValue=$(echo $nistTime | cut -d' ' -f7-7) | |
#echo $dateString | |
case $monthValue in | |
"Jan") | |
monthValue="01" | |
;; | |
"Feb") | |
monthValue="02" | |
;; | |
"Mar") | |
monthValue="03" | |
;; | |
"Apr") | |
monthValue="04" | |
;; | |
"May") | |
monthValue="05" | |
;; | |
"Jun") | |
monthValue="06" | |
;; | |
"Jul") | |
monthValue="07" | |
;; | |
"Aug") | |
monthValue="08" | |
;; | |
"Sep") | |
monthValue="09" | |
;; | |
"Oct") | |
monthValue="10" | |
;; | |
"Nov") | |
monthValue="11" | |
;; | |
"Dec") | |
monthValue="12" | |
;; | |
*) | |
continue | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment