Asterisk CLI
Asterisk CLI
The Asterisk command line interface (CLI) is reached by using the Linux shell command
asterisk -r
The Asterisk server has to be running in the background for the CLI to start.
Page Contents
General commands
Server management
AGI commands
Database handling commands
IAX Channel commands
H323 channel commands
SIP channel commands
Zap channel commands
Console channel commands
Asterisk channel MGCP commands
skinny channel commands
Asterisk channel CAPI commands
Sirrix ISDN channel commands
Batch files with CLI
See also
If you want to run a CLI command in a shell script, use the x option
For help in the CLI mode, use the help command. To get help on various applications you can use in
the extensions.conf config file, use the show applications command.
General commands
!<command>: Executes a given shell command
abort halt: Cancel a running halt
add extension: Add new extension into context
add ignorepat: Add new ignore pattern
add indication: Add the given indication to the country
agent show: Show status of agents
debug channel: Enable debugging on a channel
dont include: Remove a specified include from context
help: Display help list, or specific help on a command
include context: Include context in other context
load: Load a dynamic module by name
logger reload: Reopen log files. Use after rotating the log files.
no debug channel: Disable debugging on a channel
originate: originate a call.
remove extension: Remove a specified extension
remove ignorepat: Remove ignore pattern from context
remove indication: Remove the given indication from the country
save dialplan: Overwrites your current extensions.conf file with an exported version based on
the current state of the dialplan. A backup copy of your old extensions.conf is not saved. The
initial values of global variables defined in the [globals] category retain their previous initial
values; the current values of global variables are not written into the new extensions.conf.
(:exclaim:) Using "save dialplan" will result in losing any comments in your current
extensions.conf.
dialplan save (1.4): BROKEN, doesn't parse correctly. Overwritesyour current extensions.conf
file with an exported version based on the current state of the dialplan. A backup copy of your
old extensions.conf is not saved. The initial values of global variables defined in the [globals]
category retain their previous initial values; the current values of global variables are not
written into the new extensions.conf. (:exclaim:) Using "save dialplan" will result in losing any
comments in your current extensions.conf.
set verbose: Set level of verboseness
show applications: Shows registered applications
show application: Describe a specific application
show channel: Display information on a specific channel
show channels: Display information on channels
show codecs: Display information on codecs
show conferences: Show status of conferences
show dialplan: Show dialplan
show hints: Show registered hints
show image formats: Displays image formats
show indications: Show a list of all country/indications
show locals: Show status of local channels
show manager command: Show manager commands
show manager connect: Show connected manager users
show parkedcalls: Lists parked calls
show queues: Show status of queues, see details here
show switches: Show alternative switches
show translation: Display translation matrix
soft hangup: Request a hangup on a given channel - in Asterisk 1.6.2: "channel request
hangup <name>"
show voicemail users: List defined voicemail boxes
show voicemail zones: List zone message formats
devstate change: Change state of a custom device (new in Asterisk 1.6.0)
Server management
restart gracefully: Restart Asterisk gracefully, i.e. stop receiving new calls and restart at
empty call volume
restart now: Restart Asterisk immediately
restart when convenient: Restart Asterisk at empty call volume
Note for Asterisk 1.2: Restart now is like a reload, not a real restart it just run the reload routines
(thus open ports are not closed). Often you don't need really need to restart asterisk, instead just need
to issue e.g. 'unload chan_sip.so' and 'load chan_sip.so'.
AGI commands
show agi: Show AGI commands or specific help
dump agihtml: Dumps a list of agi command in html format
The following commands are available if the channel is built with support for libpri:
See section 3 of AT&T tr41459_99 to better understand what the output generated by the pri debug
command means.
srx reload: Reload channel driver configuration; active calls are not being terminated!
srx show ccmsgs: Disable / enable output of incoming callcontrol messages.
srx show chans: Show info about B-Channels
srx show globals: Show info about global settings
srx show groups: Show info about configured groups
srx show layers: Show info about ISDN stack (Layer 1, 2, 3)
srx show sxpvts: Show private info about active channels
srx show timers: Show info about running timers
cat batch-file\
| awk '{printf "/usr/sbin/asterisk -r -x \"%s\"\n", $0}'\
| sh
The above is very slow, though. A faster option is to use socat and write the commands directly to the
Asterisk socket.
1. !/bin/sh
while read line
do
echo -n "$line"
sleep 0.001
done \
| socat STDIN UNIX-CONNECT:/var/run/asterisk/asterisk.ctl
The short sleep is only needed to guarantee that every line is written in a separate write() call. It will
not print any output from any command, though, or even report an error. And you'll have to end your
"programs" with a "quit" line.
See also
Development branch: CLI filtering and patch 8849
Phone Genie for Asterisk Web-Based Controller for Asterisk CLI. Works fine with Asterisk 1.2.x.
How to change the CLI prompt