What is the best way to stop and start Asterisk? Does it need to be restarted when you change configuration files, or can you reload changes without disrupting service?
There are several ways to stop and start Asterisk, depending on what you want to do. You'll have two different command interfaces to use: the Linux command line, and the Asterisk command console. You should use the Asterisk console to control Asterisk.
After installing Asterisk, first reboot the system, then check to see if it is running with ps:
$ ps ax | grep asterisk
It should be, if you ran the make
config
command during installation, because this creates the
files necessary to start up automatically at boot.
Then, all you do is attach to the running Asterisk server and open the console with this command:
[root@asterisk1 ~]# asterisk -rvvv
Asterisk 1.4.4, Copyright (C) 1999 - 2007 Digium, Inc. and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'show license' for details.
=========================================================================
== Parsing '/etc/asterisk/asterisk.conf': Found
== Parsing '/etc/asterisk/extconfig.conf': Found
Connected to Asterisk 1.4.4 currently running on asterisk1 (pid = 31461)
Verbosity was 0 and is now 3
You can exit from the Asterisk console and return to the Linux Bash shell with the
quit or exit commands.
Type help to see a list of Asterisk commands. The list is probably too long for your
screen, so page up and down by holding down the Shift key and pressing Page Up/Page
Down.
Type help [commandname] to get information on specific commands:
asterisk1*CLI> help stop gracefully
Usage: stop gracefully
Causes Asterisk to not accept new calls, and exit when all
active calls have terminated normally.
Asterisk installs with the usual startup files, and is controlled from the Linux command line with these commands:
# /etc/init.d/asterisk start
# /etc/init.d/asterisk restart
# /etc/init.d/asterisk stop
# /etc/init.d/asterisk status
These are all right to use in testing, but they disrupt service so they're not appropriate for a production system. Use the Asterisk console commands to reload changes in the following configuration files without interrupting active calls:
reload
chan_sip.so
reload
chan_iax2.so
dialplan reload
dnsmgr reload
ael reload
reload
!/sbin/ztcfg
The exclamation point is used to execute external Linux commands from the Asterisk console. You can also open a Linux shell inside the Asterisk console:
*CLI> !
[root@asterisk1 ~]#
Type exit
to return to
Asterisk.
There are several ways to shutdown Asterisk:
restart gracefully
Stop accepting new calls and cold-restart when all active calls have ended.
restart now
Restart Asterisk immediately, callers be danged.
restart when
convenient
Restart Asterisk when there is no activity.
stop gracefully
Stop accepting new calls and cold-restart when all active calls have ended.
stop now
Shut down Asterisk immediately.
stop when
convenient
Stop Asterisk when there is no activity.
abort halt
Change your mind and cancel a shutdown.
Making and loading configuration changes on a running server
with a minimum of disruption is one of Asterisk's nicer features, as
cutting off callers in mid-stream won't win you any friends. However,
on a busy system, you might find yourself waiting a long time for a
graceful shutdown, so stop now
is a
useful option.
If you don't have startup files for Asterisk, or don't want it to start at boot, use this command to start up the Asterisk server:
# asterisk -cvvv
Asterisk Documentation Project: http://www.asteriskdocs.org/modules/news/
Asterisk Support: http://www.asterisk.org/support