Reboot Feature Code

I was curious to see if anybody had thought up a way to do this.

I’m attempting to create a custom feature code that when dialed would reboot the server itself. The thought would be that dialing *something would initiate a full reboot to clear up a glitch that occurs occasionally where the SIP trunk disconnects and then can’t reconnect.

Does anybody have any ideas of how to implement that?


You can use the asterisk system() cmd in a custom context to do anything you want e.g.

exten => 99991111,1,System(/sbin/reboot)

BUT, your asterisk user would not normally be able to run that command unless you have added it to your sudoers file.

asterisk ALL = NOPASSWD: /sbin/reboot

BIGGER BUT, it is never necessary to reboot your server. It is always best to find out what exactly is causing your particular “glitch” and fix it at source. Network issue seem like a cause and a

rasterisk -x ‘sip reload’ might be all it takes, failing that restarting your network if you have a recalcitrant DHCP service at a little lower level.

Cool, that’s good to know. Thanks for the tip on the network as well! It happens very rarely and randomly so it’s hard to narrow down.


I know this is a really old thread but it’s the first google result and I just encountered a situation this morning where my provider had a glitch and the sip registration was reported as online but it was not functional. Other (non freepbx) telephone systems also had issues. The only way to resolve this was a reboot.

Dicko’s solution has the minor issue that the calling phone does not receive a hangup signal, therefore the line will stay open without any audio.
My solution:

In extensions_custom.conf:

exten => s,1,System(/bin/sh -c "(/usr/bin/sleep 3 && sudo /sbin/reboot -f) &")
same => n,Hangup()
  • Create Admin → Custom Destination with with destination restart-system,s,1
  • Create Apps → Misc Apps with custom feature code and target custom-destination

Rebooting the whole machine doesn’t reset any more of the SIP state that restarting Asterisk.

channel request hangup all

You are both absolutely right from a technical standpoint. However, the discussion title is “Reboot Feature Code” and I think it’s sensible to have such a thing in certain situations.
Let me explain why: The FPBX instance in question is “managed” by myself for others (private, unpaid, only kindness). They just don’t have the technical knowledge to troubleshoot problems themselves but it’s also not possible for me to give 24/7 remote support. Having the possibility to restart the system by telling someone else to call a specific feature code can be an easy way to temporarily work around problems until I have time to look at it again.
Maybe next time it’s another system component that starts to fail and asterisk itself is working fine. Then a restart/reload of asterisk won’t help and I’m better off restarting everything.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.