Advertisement
Guest User

Datetime sanity check

a guest
Jan 21st, 2012
452
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.31 KB | None | 0 0
  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
Add Comment
Please, Sign In to add comment
Advertisement