You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

lock_age.sh 598B

123456789101112131415161718192021
  1. #! /bin/bash
  2. if lockfile -r0 -! /home/integration/deploy/lock.file &> /dev/null
  3. then
  4. # If we could not get the lock, check how old the lock file is
  5. DATE=$(date +%s)
  6. # What if the file is not there any more?
  7. LOCK_AGE=$(stat -c %Z /home/integration/deploy/lock.file)
  8. AGE=$[($DATE - $LOCK_AGE)/60]
  9. if [ "$AGE" -gt "20" ]
  10. then
  11. echo lock.file is $AGE min old.
  12. ./cleanup.sh
  13. # else
  14. # echo lock.file is $AGE min old.
  15. fi
  16. else
  17. # If we got the lock, do a cleanup (releasing the lock) just in case something has still been left running
  18. ./cleanup.sh &> /dev/null
  19. fi