Skip to content

Instantly share code, notes, and snippets.

@shudarshon
Created July 7, 2017 17:52
Show Gist options
  • Save shudarshon/e8db29a8ce556b2aae49513e3d1b30f3 to your computer and use it in GitHub Desktop.
Save shudarshon/e8db29a8ce556b2aae49513e3d1b30f3 to your computer and use it in GitHub Desktop.
This script checks if celerybeat is service is down then it will notify admin via email then it will keep the celerybeat running.
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/home/ubuntu
status=$(sudo supervisorctl status celerybeat | grep -o FATAL)
if [ "$status" == "FATAL" ]
then
echo "Celerybeat service is Down!" | mail -s "Celerybeat Down" admin@domain.com, admin2@domain.com, admin3@domain.com > /dev/null 2>&1
sudo supervisorctl restart all > /dev/null 2>&1
status=$(sudo supervisorctl status celerybeat | grep -o RUNNING)
if [ "$status" == "RUNNING" ]
then
echo "Celerybeat service is Up!" | mail -s "Celerybeat Up" admin@domain.com, admin2@domain.com, admin3@domain.com > /dev/null 2>&1
fi
fi
#run this script every 5 minutes
#cronjob email in `sudo crontab -e`
*/5 * * * * /bin/bash /home/ubuntu/celerybeat_alert.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment