4

I started Asterisk CLI with the below command:

asterisk -vvvvvvc

When I try to exit CLI using exit or quit, I see the errors below:

*CLI> exit
No such command 'exit' (type 'core show help exit' for other possible commands)
*CLI> quit
No such command 'quit' (type 'core show help quit' for other possible commands)

I am able to exit CLI using ^C. Why is exit and quit not working?

live-love
  • 48,840
  • 22
  • 240
  • 204
Blesson Jose
  • 698
  • 9
  • 14

3 Answers3

7

As the error message states, there is no "exit" or "quit" command. But there is an entry in the Asterisk wiki discussing how to stop Asterisk from the CLI: https://wiki.asterisk.org/wiki/display/AST/Stopping+and+Restarting+Asterisk+From+The+CLI

The command you should be using is "core stop" (note, however, that this actually kills asterisk, not only the shell) and you have a few options available for it:

*CLI> help core stop
core stop gracefully           -- Gracefully shut down Asterisk
core stop now                  -- Shut down Asterisk immediately
core stop when convenient      -- Shut down Asterisk at empty call volume

In any case, by starting asterisk with the -c flag you are not starting it as a service, but in foreground, meaning that you have to leave your shell open if you want Asterisk to continue running.

You should be starting it without the -c flag and then use -r to connect to it: https://wiki.asterisk.org/wiki/display/AST/Connecting+to+the+Asterisk+CLI

Then you can just quit the "remote shell" by using ^C. Asterisk will keep running in background. I personally like to use daemontools to start and supervise services: http://cr.yp.to/daemontools/svc.html.

Hope it helps!

marcelog
  • 7,062
  • 1
  • 33
  • 46
3

You should start the asterisk daemon first. Then connect to the console.:

Starting the daemon is as simple as:

$>asterisk

Then you can connect to the console with all the verbosity:

$>asterisk -rvvvvvv

I don't believe there is any graceful exit using asterisk -c as you have.

JNevill
  • 46,980
  • 4
  • 38
  • 63
  • `core stop gracefully` exits from console after stopping asterisk service. Then following the commands as you listed should work. `asterisk -c` actually starts a process in foreground. Anyway, the combined solution from you and the accepted answer make more sense. +1 – Fr0zenFyr Nov 30 '18 at 09:01
1

If you are running in the foreground, if you started Asterisk such as:

asterisk -gcvvvvvvvvv

If you try the quit command, it won't work, because you are running in the foreground.

Try to connect to the Asterisk console running in background, then use quit or exit:

[root@localhost asterisk]# asterisk -rvvv

localhost*CLI> exit

-r: Connect to Asterisk running in the background and present a Asterisk CLI

-v: The verbose command. Add more ā€˜v’:s to get more messages.

Output:

Asterisk cleanly ending (0). Executing last minute cleanups

To check if asterisk is running:

[root@localhost asterisk]# ps -ef | grep asterisk

To stop the Asterisk process:

cli> core stop now

To start the Asterisk service:

 [root@localhost asterisk]# service asterisk start

To stop the Asterisk service:

 [root@localhost asterisk]# service asterisk stop
live-love
  • 48,840
  • 22
  • 240
  • 204