SHARE
TWEET

Datetime sanity check

a guest Jan 21st, 2012 341 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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top