I have a Python script that runs 24/7 on an AWS instance that does some web scraping and data analytics. Depending on the data, it sometimes overruns and I get the following warning in my sentry logs (https://getsentry.com/):
u'Execution of job "analytics_scheduler (trigger: cron[day_of_week='*', hour='0'], next run at: 2016-01-17 00:00:00)" skipped: maximum number of running instances reached (1)'
When this happens I have to ssh into the instance and run a bash restart script (./restart.sh) that contains three commands to get it up and running again and continue where it left off. Is there a way I can capture this exact warning and run restart.sh when it occurs so I don’t have to keep running the restart script manually? I don't want any actions to occur on any other warnings except this exact one. I am wondering what the best solution would be for a problem like this.
Thanks!