No public Twitter messages.
  • facebook
  • twitter
  • linkedIn

Simple Asterisk Watchdog

  • April 14th,
  • by Razvan Gavril

Asterisk is pretty stable but from time to time it may crash so it’s better to be prepared for that. A hour of downtime may cost a lot of money if you have a heavy used server. Want a quick solution to automatically restart asterisk after a crash? This little bash script will do the trick.
Create a file named in /usr/local/bin with the fallowing content :


asterisk -rx 'core show version' &> /dev/null

if [[ "$errcode" != "0" ]] ;then
/etc/init.d/asterisk stop
sleep 3
/etc/init.d/asterisk start

Then edit /etc/crontab and add :
*/2 * * * * root /usr/local/bin/

2 Comments Post a comment ↓

  1. Darryl said:

    Thanks for this, useful little snippet!

    May 24, 2010

  2. Tsunami Australia said:

    TYVM for this, greatly appreciated. I’ve been looking around a bit this morning and it seems watchdog is not nearly as well documented as say webmin or elastix etc so this was a great help. Now to implement WD for other services on my other servers.

    December 3, 2012

Leave your comment: