[asterisk-users] Script to softly restart Asterisk each midnight to clean locked channels
Mindaugas Kezys
mkezys at gmail.com
Thu Mar 19 09:28:28 CDT 2009
As Asterisk has inner problems and channels very often locks we have such
script to restart Asterisk each midnight.
We (our clients) mostly use v1.4.18.1. We can't upgrade to newer versions
because there are too much changes which would brake our system
(realtime/sip/iax2/cdr/etc/etc).
Script soft hangups all alive channels in dirty way then kills Asterisk and
starts it up.
Hope it will be useful to somebody.
Corrections/comments welcome.
#! /bin/sh
# Script to restart asterisk softly by Kolmisoft
# crontab
# 0 0 * * * /usr/local/mor/asterisk_nice_restart.sh
# tell Asterisk do not accept new calls
asterisk -rx 'stop gracefully' >/dev/null
# read all channels
asterisk -rx 'core show channels verbose' | sed '1d' > /tmp/f1
cat /tmp/f1 | awk '{split ($0,a," "); print a[11]}' > /tmp/f2
# hangup all alive channels
for i in `cat /tmp/f2`; do
asterisk -rx "soft hangup $i " > /dev/null
done
# let asterisk to stop by itself
sleep 5
# kill remainings
killall -9 safe_asterisk
killall -9 asterisk
# start fresh and ready to work!
/etc/init.d/asterisk start
# clean
rm -rf /tmp/f1
rm -rf /tmp/f2
Regards,
Mindaugas Kezys
http://www.kolmisoft.com
VoIP Billing and Routing Solutions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20090319/0fdf36ab/attachment.htm
More information about the asterisk-users
mailing list