Emergency stop usin shell script: asterisk -r -x 'stop now'


#1

I try to make a sh shell script that can do a emergency stop using this command line:

asterisk -r -x ‘stop now’

and a reboot as well:

asterisk -r -x ‘reboot now’

It lookes like i does not work this way ??
Can it be done ?!

Best reg Arne.


#2

[quote=“arne22”]I try to make a sh shell script that can do a emergency stop using this command line:

asterisk -r -x ‘stop now’

and a reboot as well:

asterisk -r -x ‘reboot now’[/quote]
Um… You’re trying to give a command to Asterisk after you’ve killed it???

What are you trying to do? Reboot the linux system? If so, Asterisk won’t (can’t) reboot it for you.

To reboot the system in a shell script (potentially a very dangerous thing to do!), you simply use the command:

reboot


#3

I issue the following script once per day at 12:05 AM. It takes the phone system offline for about a minute, but it really keeps it from getting flakey after a few days. I redirect the output of the entire thing to a log file so I can see if at any point there were issues while restarting Asterisk.

[code]#!/bin/sh

date
echo "Stopping Asterisk…"
amportal stop > /dev/null 2>&1
echo "Waiting for 5 seconds…"
sleep 5s
if (ps -A | grep asterisk > /dev/null 2>&1) then
echo "Asterisk is still running"
echo "Killing rogue Asterisk processes…"
amportal kill > /dev/null 2>&1
echo "Waiting for 5 seconds…"
sleep 5s
fi
echo "Starting Asterisk…"
amportal start > /dev/null 2>&1
[/code]


#4

try

killproc asterisk

#5

On the other hand, maybe what you’re looking for is:

asterisk -r -x ‘restart now’

rather than reboot.


#6

Thanks … will try the commands :smile: