PBX in a Flash for Newbies

Stopping the System


Stopping the System

The Asterisk PBX server must be stopped first before you shutdown computer. The mySQL database must be properly shutdown or the configuration will become corrupted. The first step is stopping Asterisk, the second is issuing the shutdown command for Linux. During the Linux shutdown, it will stop the mySQL database properly.

  1. Stopping Asterisk PBX

    Issue the following command at the Asterisk command line:

    CLI> stop gracefully

    You should then be returned to the Linux prompt.

    Another option is to stop the Asterisk PBX at the Linux command line:

    root@pbx:~ $ amportal stop (amportal is the original name for Asterisk)

  2. Shutting Down the Linux server
  3. After Asterisk is gracefully stopped, you can shutdown the PC using the following command at the root prompt:

    root@pbx:~ $ shutdown -h now (the -h means halt)

Restarting Linux and Asterisk

  • Rebooting the Linux server
  • if you want to reboot the system instead of shutting down, first stop Asterisk PBX using one of the methods explained previously then use the following command:

    root@pbx:~ $ shutdown -r now (the -r means restart)

    The server will shutdown and then reboot.

Restarting Asterisk without shutting down

Sometimes you want to stop Asterisk and restart it without shutting down Linux, here's how:

  • At the Asterisk command line prompt:

    CLI> restart now
  • Or at the Linux command prompt:

    root@pbx:~ $ amportal restart
  • Or if you want to shut it down, and then start it up later:

    root@pbx:~ $ amportal stop

    root@pbx:~ $ amportal start

Creating Scripts

You can make a script with the commands needed to shutdown and restart your server as you need it. So rather than remembering if you stopped Asterisk before you shut it down, you can issue a command like pbx-stop instead. Here's the scripts I created in a text editor to stop PiaF gracefully and to restart it:

  • pbx-stop

    I used a text editor to create a file called pbx-stop. You can use the nano text editor from the Linux command line or use the editor in Webmin's File Manager application (a lot nicer!). Here's the two lines in it:

    amportal stop
    shutdown -h now
    

    I saved it in /usr/sbin directory and made it executable for the root user only using the following command:

    root@pbx:~ $ chmod 744 /usr/sbin/pbx-stop

    Now to stop PiaF, I just have to type:

    root@pbx:~ $ pbx-stop

  • pbx-reboot

    I used my trusty text editor to create a file called pbx-reboot. Here's the two lines in it:

    amportal stop
    shutdown -r now
    

    I saved it in /usr/sbin directory and made it executable for the root user only using the following command:

    root@pbx:~ $ chmod 744 /usr/sbin/pbx-reboot

    Now to stop PiaF, I just have to type:

    root@pbx:~ $ pbx-reboot

    Asterisk stops gracefully and then Linux shuts down and reboots the computer.


Go to the

Introduction
to Networking

Online Book

Go to the

PBX in a Flash

Home Page

Go to the

FreePBX

Home Page

Return to the

PBX in a Flash
for Newbies

home page

Copyright April 2008 - Eugene Blanchard