Last active
January 6, 2024 22:14
-
-
Save discarn8/839e9643beadde266791629bfffe145e to your computer and use it in GitHub Desktop.
BASH_Program_Check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /bin/bash | |
| # Add an entry in your crontab to run this script on a timed interval | |
| logfile="/var/log/app_check.log" | |
| case "$(pidof app | wc -w)" in | |
| 0) echo "App found not running, (re)starting app: $(date)" >> $logfile | |
| DISPLAY=:0 /home/jdoe/app_script & | |
| ;; | |
| 1) echo "App found running, all OK: $(date)" >> $logfile | |
| ;; | |
| *) echo "Multiple instances of app found running. Stopping & restarting app: $(date)" >> $logfile | |
| kill $(pidof app | awk '{print $1}') | |
| ;; | |
| esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment