Skip to content

Instantly share code, notes, and snippets.

@logikal
Created November 21, 2018 03:24
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 logikal/26449734b8d9e07e47f7cf87dc0189c9 to your computer and use it in GitHub Desktop.
Save logikal/26449734b8d9e07e47f7cf87dc0189c9 to your computer and use it in GitHub Desktop.
Ever wondered how far off your clock was? now you can know.
#!/usr/bin/env bash
# finds the maximum clock drift in the last 30 days
# using the stats files kept in /var/log/ntpstats
# We need somewhere temporary to keep our concatenated results
TMPFILE=$(mktemp) || exit 1
FILELIST=$(find /var/log/ntpstats/ -mtime -31 -type f)
cut -d' ' -f 5 $FILELIST| sort -g > $TMPFILE
MIN_OFFSET=$(head -n 1 $TMPFILE)
MAX_OFFSET=$(tail -n 1 $TMPFILE)
echo "$MIN_OFFSET $MAX_OFFSET"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment