Simple Asterisk Watchdog
- April 14th,
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 asterisk-watchdog.sh in /usr/local/bin with the fallowing content :
#!/bin/bash asterisk -rx 'core show version' &> /dev/null errcode=$? if [[ "$errcode" != "0" ]] ;then /etc/init.d/asterisk stop sleep 3 /etc/init.d/asterisk start fi
Then edit /etc/crontab and add :
*/2 * * * * root /usr/local/bin/asterisk-watchdog.sh