No Shutdown

From Etel

Jump to: navigation, search

Contents

Title

No Shutdown

Problem

Asterisk can sometimes go down for whatever reason it chooses to. Whether is a "dohicky" error message or something obscure. All versions have been known to quite simply stop from time to time.

Solution

Create a simple script one line script and run it from cron.

echo "ps -C asterisk || { asterisk & }" > /usr/bin/checkast
chmod +x /usr/bin/checkast

Run this from cron according to your liking. It will check if Asterisk is running and if it is, it will do nothing. If it is not running, it will start it for you.

Discussion

There had been times when I would come back to one of my PBX's and see Asterisk mysteriously stopped. I would spend hours parsing through logs to see why it stopped to no avail the majority of the times. I created my own script similar to the one liner above which runs from cron every 2 minutes. My own modified version of that one liner also sends me an email message if it has to start Asterisk up. This comes in handy for administrators of multiple PBX's since it always ensures that Asterisk is running before someone calls to notify that admin of the problem.

Personal tools