I have a simple bash script scheduled to run every 10 minutes, which checks for the PID of any service, and if it is not found, it sends an email alert:
#!/bin/bash if pgrep "mysql" > /dev/null then echo "MYSQL Running" else echo "ALERT Stopped" # Sends Email Alert blah blah fi
The issue is that if somehow the required service is down permanently, it keeps sending emails every 10 minutes. How can I set up a check so that if the service is down and an email sent once, then no emails should be sent until the service comes up again. Then, if the service is subsequently down again, a new email should be sent.