Created
April 27, 2023 11:44
-
-
Save anzz1/608f91ded532747d0d2e398e09ae03fc to your computer and use it in GitHub Desktop.
time.sh
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/sh | |
# dt=$(echo -ne "GET / HTTP/1.1\r\nHost: whatismyip.akamai.com\r\nAccept: text/plain\r\nConnection: close\r\n\r\n" | nc -w1 whatismyip.akamai.com 80 | awk -F': ' '/Date: /{print $2;exit}') | |
# t=$(date -d "$dt" +%s) | |
a=$((printf "c%47s" | nc -uw1 pool.ntp.org 123 | xxd -s40 -l4 -p) 2>/dev/null) | |
if [ ! -z "$a" ]; then | |
b=$((printf "%d" 0x$a) 2>/dev/null) | |
if [ "$b" -gt 2208988800 ] 2>/dev/null; then | |
t=$((0x$a-2208988800)) | |
echo $t $(date -d "@$t") | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment