Advertisement
Guest User

Datetime sanity check

a guest
Jan 21st, 2012
419
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. me="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")"
  4. now=`date +%s`
  5. filetime=`stat -f %m $me`
  6.  
  7.  
  8. if [ "$now" -lt "$filetime" ]; then
  9.  echo "System time is too old. Updating system time."
  10.  date -f %s $filetime
  11. else
  12.  # Touch the file to update the mtime.
  13.  touch $me
  14. fi
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement