Wednesday 20 September 2017

Grandstream VOIP phones - Mass reboot script

Here is a little snippet of code that I've written to reboot all Grandstream phones on a VOIP system (Asterisk).
It's very simple, it queries the Asterisk running process for all extension numbers, then uses the SIP NOTIFY method to send a reboot to the phones.

I've tested this on GXP1620 handsets so far and it works great, the phone reboots almost immediately. I've added a 25 second sleep in between each phone reboot, the idea is not to reboot your entire estate at the same time, leaving no phones available. Change that as required. My plan is to schedule this on a cron job overnight anyway, but still spacing reboots out seems to be more sensible.

Caveats: The script simply grabs all extensions and iterates through them all, so it'll try extensions that aren't Grandstream, or aren't phones (e.g. trunks) but those will just get ignored anyway.

EXTENSION_LIST=`asterisk -rx "sip show peers" | cut -d "/" -f 1 |cut -d " " -f 1 | grep -o '[0-9]*'`
while read -r line; do
    echo "Rebooting extension: $line ..."
asterisk -rx "sip notify spa-reboot $line"
echo "(sleep)"
sleep 25
done <<< "$EXTENSION_LIST"

It's very simple and rough but will do the job!


  1. Awesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work! Verizon flip phones for sale

  2. Thanks for your beyond belief blogs stuff.
    business tampa fl

  3. How can I use that to reboot phone if it becomes unreachable for X amount of time ?
    Thank You

  4. I discovered your website internet site online and appearance a couple of your early posts. Always maintain inside the top notch operate. I additional your Rss to my MSN News Reader. Seeking toward reading much more on your part down the road!… VoIP Service Near Me

  5. If you are looking for more information about flat rate locksmith Las Vegas check that right away. best phones under 9000 with fingerprint sensor

  6. Wow, cool post. I'd like to write like this too - taking time and real hard work to make a great article... but I put things off too much and never seem to get started. Thanks though. best 4g mobile under 4000 amazon


Note: only a member of this blog may post a comment.