Mindaugas Kezys
2009-Mar-19 14:28 UTC
[asterisk-users] Script to softly restart Asterisk each midnight to clean locked channels
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
Miguel Molina
2009-Mar-19 15:46 UTC
[asterisk-users] Script to softly restart Asterisk each midnight to clean locked channels
Mindaugas Kezys escribi?:> > As Asterisk has inner problems and channels very often locks we have > such script to restart Asterisk each midnight. ><snip> That is the things we must help to solve for not having to do to something like this on asterisk servers. Fortunately I use 1.4.22 version which has proved to me to be quite stable, judging from this uptime: System uptime: 1 week, 2 days, 19 hours, 22 minutes, 53 seconds Last reload: 10 hours, 31 minutes, 33 seconds Upgrading to 1.4.23.1 resulted in random core dumps (suspecting attended transfers issue) but unfortunately I've had no time to debug it and make a good bug report. My case is a 24/7/365 non-stop call center, so I didn't have another choice but to rollback. I hope some of us just can help asterisk be better by trying to use the latest version at least on testing environments, to not having to maintain an "internal version" and cherrypicking patches that may or may not resolve the issues that we could experience. Just my 2 cents... -- Ing. Miguel Molina Grupo de Tecnolog?a Millenium Phone Center PBX: (+57 1)6500800 ext. 1201 Fax: (+57 1)6500816 M?vil: (+57)3138873587
J. Oquendo
2009-Mar-19 16:32 UTC
[asterisk-users] Script to softly restart Asterisk each midnight to clean locked channels
On Thu, 19 Mar 2009, Miguel Molina wrote:> Mindaugas Kezys escribi?: > > > > As Asterisk has inner problems and channels very often locks we have > > such script to restart Asterisk each midnight. > > > <snip> >Why restart Asterisk, free up the channel...