Asterisk not running on reboot

Asterisk system working properly. But on reboot it need to run manually by following command.

asterisk

I tried following methods. but no use

    1. /etc/rc.local method by custom shell script to start.
    1. chkconfig asterisk on

I want to run the asterisk always even after reboot for seamless working…
please help me.

On what OS is Asterisk running? I haven’t seen chkconfig for a couple of years.

I am using CentOS 7.5

verify the service status

chkconfig --list |  grep asterisk

Asterisk is already in chkconfig . and its in on state from 2-5. But its not running on startup… I have written a custom shell script to run asterisk. The asterisk command not working (no error showing such as command not found etc). if the the same script run manually after startup it work properly…

Asterisk 16 now supports systemd, so you may want to try/check out the contrib/systemd directory (instead of using the old-style SysV/chkconfig scripts). There is a README.txt file in there that you should read (and then figure out only which other scripts you need, depending on your needs/implementation), but here are some example commands you may want to run:

Disable System V Init:
service asterisk stop
chkconfig --del asterisk
rm /etc/init.d/asterisk

cp asterisk.service /lib/systemd/system/
cp asterisk-cli.socket /lib/systemd/system/

systemctl enable asterisk.service
systemctl enable asterisk-cli.socket

systemctl restart asterisk.service
systemctl restart asterisk-cli.socket

You can then verify that they are running using:

systemctl status asterisk.service
systemctl status asterisk-cli.socket

Hope this helps

I am using Asterisk 13.21 certified version.

Well, I apologize in advance if I can’t help you in more debt. I’m currently testing with Asterisk 16 installed on CentOS 7.6 (& I actually skipped over Asterisk 13 entirely).

If chkconfig --list shows that run-levels 2-5 are enabled for the asterisk process, then I suggest that you try replacing your “custom shell script” by the default one that asterisk provides (/etc/init.d/asterisk). In doing so, please make sure the following 2 default files are present:

/usr/sbin/asterisk
/usr/sbin/safe_asterisk

If you find that it works with default scripts then you know it’s a problem with your start up script (e.g.: Perhaps you did not write the start() function, required at boot time, whilst when you manually start it you are using “service asterisk restart”).

(Note: I will assume the rest of you installation is generic and correct. I’m also thinking that defaults should at least get Asterisk up and running, with the above.)

Hope this helps

safe_asterisk is a shell script, not a binary!

2 Likes

Thank you David. I have edited my post (changing binaries to now be simply files) to correct. I did notice that in the past, but in replying I did not even open/look at /usr/sbin/safe_asterisk as it’s contents were unimportant. My suggestion is still relevant. The key is to try the default setup files to see if that works, in order to determine if the issue is with vimals “custom shell script” or with the setup.

Hi vimals,

If your issue is still not rectified, you can use these commands:

make config (run this command in asterisk source dir)
chkconfig asterisk on

start asterisk using : /etc/init.d/asterisk start

start asterisk using :
/etc/init.d/asterisk start
only show some message as follows
Starting asterisk (via systemctl)
But actually its not starting…

I have a custom script to run the asterisk as well as the php script for the AMI handling.
But issue is not script not running, while the script is not running on boot up.
If the same script manually run after boot up. It works fine. The default asterisk initializing script even not working.
I tried another by new line to /etc/rc.local

/usr/sbin/asterisk

also tried

asterisk

but none of them running the asterisk. So I think that its not issue with the script

One import thing noted that, after disabling selinux the custom start up script working fine.

See my answer to the other thread. With the SELinux errors you are getting it is not surprising this is happening

Agree’d. I think you’ve proven that both your custom script and the default Asterisk start up script exhibit the same behaviour. i.e.: Both work when SELinux is disabled, or don’t work when it’s enabled. Thus, this isn’t an Asterisk problem but rather an SELinux configuration problem.

Either do as david551 suggests in other " [Errors dumping in /var/log/messages]" (Errors dumping in /var/log/messages) thread and disable SELinux, or figure out how to configure SELinux on your server.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.