Sophie

Sophie

distrib > Mandriva > 2008.1 > i586 > by-pkgid > c7095aefea7b97fbd2a596dcbfb9d481 > files > 430

asterisk-docs-1.4.26.1-1mdv2008.1.i586.rpm

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Starting Asterisk Without Scripts</title><link rel="stylesheet" href="styles.css" type="text/css" /><meta name="generator" content="DocBook XSL Stylesheets V1.69.1" /><link rel="start" href="index.html" title="Asterisk™: The Future of Telephony" /><link rel="up" href="asterisk-CHP-3.html" title="Chapter 3. Installing Asterisk" /><link rel="prev" href="asterisk-CHP-3-SECT-10.html" title="Loading libpri Without Script" /><link rel="next" href="asterisk-CHP-3-SECT-12.html" title="Directories Used by Asterisk" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Starting Asterisk Without Scripts</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="asterisk-CHP-3-SECT-10.html">Prev</a> </td><th width="60%" align="center">Chapter 3. Installing Asterisk</th><td width="20%" align="right"> <a accesskey="n" href="asterisk-CHP-3-SECT-12.html">Next</a></td></tr></table><hr /></div><div class="sect1" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="asterisk-CHP-3-SECT-11"></a>Starting Asterisk Without Scripts</h2></div></div></div><p>Asterisk can be loaded in a variety of ways. The easiest way is to
    start Asterisk by running the binary file directly from the Linux
    command-line interface. If you are running a system that uses the
    <span class="emphasis"><em>init.d</em></span> scripts, you can easily start and restart
    Asterisk that way as well. However, the preferred way of starting Asterisk
    is via the <span class="emphasis"><em>safe_asterisk</em></span> script.</p><div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="asterisk-CHP-3-SECT-11.1"></a>Console Commands</h3></div></div></div><p>The Asterisk binary <a id="I_indexterm3_tt363" class="indexterm"></a>is, by default, located at
      <span class="emphasis"><em>/usr/sbin/asterisk</em></span>. If you run
      <span class="emphasis"><em>/usr/sbin/asterisk</em></span>, it will be loaded as a daemon.
      There are also a few switches you should be aware of that allow you to
      (re)connect to the Asterisk CLI, set the verbosity of CLI output, and
      allow core dumps if Asterisk crashes (for debugging with
      <span class="emphasis"><em>gdb</em></span>). To explore the full range of options, run
      Asterisk with the -<code class="literal">h</code> switch:</p><a id="I_programlisting3_tt364"></a><pre class="programlisting"># <strong class="userinput"><code>/usr/sbin/asterisk -h</code></strong>       </pre><p>Here is a list of the most commonly used options:</p><div class="variablelist"><dl><dt><span class="term">
              <code class="literal">-c</code>
            </span></dt><dd><p>Console. <a id="I_indexterm3_tt365" class="indexterm"></a>This will start Asterisk as a user process (not as a
            server), and will connect you to the Asterisk CLI. This option is
            good when you are debugging your startup parameters, but should
            not be used for a normal system (if Asterisk is already running,
            this option will not work and will issue a complaint).</p></dd><dt><span class="term">
              <code class="literal">-v</code>
            </span></dt><dd><p>Verbosity. This<a id="I_indexterm3_tt366" class="indexterm"></a> is used to set the amount of output for CLI
            debugging. The more “v”s, the more verbose.</p></dd><dt><span class="term">
              <code class="literal">-g</code>
            </span></dt><dd><p>Core dump. <a id="I_indexterm3_tt367" class="indexterm"></a>If Asterisk were to crash unexpectedly, this would
            cause a core file to be created for later tracing with
            <span class="emphasis"><em>gdb</em></span>. You generally do not use this in
            production, unless you are writing code for Asterisk and want to
            debug any resulting crashes.</p></dd><dt><span class="term">
              <code class="literal">-r</code>
            </span></dt><dd><p>Remote. <a id="I_indexterm3_tt368" class="indexterm"></a>This is used to reconnect remotely to an already
            running Asterisk process. (The process is remote from the
            standpoint of the console connecting to it but is actually a local
            process on the machine. This has nothing to do with connecting to
            a remote process over a network using a protocol such as IP, as
            this is not supported.) This is the most common option and it is
            what you would use to connect to Asterisk on a system where it is
            running as a daemon/service that was started by init at boot
            time.</p></dd><dt><span class="term">
              <code class="literal">-x "<em class="replaceable"><code>&lt;CLI
          command&gt;</code></em>"</code>
            </span></dt><dd><p>Execute. Using this<a id="I_indexterm3_tt369" class="indexterm"></a> command in combination with -<code class="literal">r</code> allows you to execute a CLI command
            without having to connect to the CLI and type it manually. An
            example would be to send a restart, which you would do by typing
            <code class="literal">asterisk -rx "reload"</code> from the command
            line.</p></dd></dl></div><p>Let’s look at some examples. If you want to start Asterisk as a
      user program (because you are tweaking your config and will be starting
      and stopping it several times), and you want a verbosity level of 3, use
      the following command:</p><a id="I_programlisting3_tt370"></a><pre class="programlisting"># <strong class="userinput"><code>/usr/sbin/asterisk -cvvv</code></strong>      </pre><p>If the Asterisk process is already running (for example, if you
      have installed Asterisk as part of the init process of the system), use
      the reconnect switch, like so:</p><a id="I_programlisting3_tt371"></a><pre class="programlisting"># <strong class="userinput"><code>/usr/sbin/asterisk -vvvr</code></strong>    </pre><p>If you want Asterisk to dump a core file after a crash, you can
      use the -<code class="literal">g</code> switch when starting
      Asterisk:</p><a id="I_programlisting3_tt372"></a><pre class="programlisting"># <strong class="userinput"><code>/usr/sbin/asterisk -g</code></strong>       </pre><p>To execute a command without connecting to the CLI and typing it
      (perhaps for use within a script), you can use the -<code class="literal">x</code> switch in combination with the -<code class="literal">r</code> switch:</p><a id="I_programlisting3_tt373"></a><pre class="programlisting"># <strong class="userinput"><code>/usr/sbin/asterisk -rx "restart now"</code></strong>
# <strong class="userinput"><code>/usr/sbin/asterisk -rx "database show"
# <strong class="userinput"><code>/usr/sbin/asterisk -rx "sip show peers"</code></strong></code></strong>        </pre><p>If you are experiencing crashes and would like to output to a
      debug file, use the following command:</p><a id="I_programlisting3_tt374"></a><pre class="programlisting"># <strong class="userinput"><code>/usr/sbin/asterisk -vvvvc | tee /tmp/debug.log</code></strong>     </pre><p>Note that you do not have to use the <code class="literal">v</code> switch
      if you do not want the system to provide detailed output of what is
      going on. On a busy system, you may not want to get any output, as it
      can interfere with whatever you are doing on the console.</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="asterisk-CHP-3-SECT-10.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="asterisk-CHP-3.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="asterisk-CHP-3-SECT-12.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Loading libpri Without Script </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Directories Used by Asterisk</td></tr></table></div><div xmlns="" id="svn-footer"><hr /><p>You are reading <em>Asterisk: The Future of Telephony</em> (2nd Edition for Asterisk 1.4), by Jim van Meggelen, Jared Smith, and Leif Madsen.<br />
       This work is licensed under the <a href="http://creativecommons.org/licenses/by-nc-nd/3.0/">Creative Commons Attribution-Noncommercial-No Derivative Works License v3.0</a>.<br />
       To submit comments, corrections, or other contributions to the text, please visit <a href="http://oreilly.com/catalog/9780596510480/">http://www.oreilly.com/</a>.</p></div></body></html>