[asterisk-users] Can't restart asterisk from script

Steve Edwards asterisk.org at sedwards.com
Wed Dec 9 22:29:00 CST 2009


On Wed, 9 Dec 2009, Michelle Dupuis wrote:

> I'm running * 1.4 and can successfully restart asterisk from the command 
> line with: /usr/sbin/asterisk -r -x "restart gracefully"
>
> However, I have a cron job that tries to restart asterisk and gets this 
> error:
>
> No such command 'restart gracefully' (type 'help restart gracefully' for 
> other possible commands)

By "cron job" do you mean an entry in <the-user-executing-asterisk>'s 
crontab like one of the following?

@daily /usr/sbin/asterisk -r -x "restart gracefully"
@daily /usr/sbin/asterisk -r -x 'restart gracefully'
@daily /usr/sbin/asterisk -r -x restart gracefully
@daily /scripts/restart-when-convenient.sh

The first 2 work, the 3rd doesn't. If you are using something like the 
4th, the error is in your script so you should post the script.

The difference between the first 2 is that 1 uses double quotes and 2 uses 
single quotes. Quotes mean "pass everything between the quotes as a single 
argument." Double quotes mean "evaluate any expressions or environment 
variables before passing." Single quotes mean "pass everything literally, 
without evaluation or substitution."

Single quotes are "better" than double quotes because we already know 
there is nothing to evaluate or substitute in "restart gracefully" so 
there is no need to pass the quoted string through the 
evaluation/substitution code in the shell.

The 3rd doesn't work because just "restart" is passed as the argument to 
the "x" option and "restart" by itself is not a valid Asterisk command.

Please paste your crontab if you still need help.

-- 
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards       sedwards at sedwards.com      Voice: +1-760-468-3867 PST
Newline                                              Fax: +1-760-731-3000



More information about the asterisk-users mailing list