check_last_update.sh 768 B

123456789101112131415161718192021
  1. #!/bin/bash
  2. # LinuxGSM check_last_update.sh function
  3. # Author: Daniel Gibbs
  4. # Website: https://linuxgsm.com
  5. # Description: Checks lock file to see when last update happened.
  6. # Will reboot server if instance not rebooted since update.
  7. if [ -f "${lockdir}/${selfname}-laststart.lock" ]; then
  8. laststart=$(cat "${lockdir}/${selfname}-laststart.lock")
  9. fi
  10. if [ -f "${lockdir}/lastupdate.lock" ]; then
  11. lastupdate=$(cat "${lockdir}/lastupdate.lock")
  12. fi
  13. if [ -f "${lockdir}/lastupdate.lock" ]; then
  14. if [ ! -f "${lockdir}/${selfname}-laststart.lock" ]||[ "${laststart}" -lt "${lastupdate}" ]; then
  15. fn_print_info "${selfname} has not been restarted since last update"
  16. fn_script_log_info "${selfname} has not been restarted since last update"
  17. command_restart.sh
  18. fi
  19. fi