Bash file age check snippet

if [[ -f $BACKUP_LOCKFILE ]]; then
  #Check age
  if [[ $(( $( date +%s ) - $(stat -c %Y $BACKUP_LOCKFILE ) )) -gt $BACKUP_MAXLENGTH_SECS ]]; then
    echo "Backup takes too long"
  else
    echo "Doing backup"
  fi    
fi