Cron Job To Start Asterisk on Reboot

I have Freepbx running well on Amazon AWS, however every time the system reboots (which can happen sometimes when Amazon is doing maintenance to AWS), my whole system goes down until I can manually go in and start Asterisk

I just have to run the following command after reboot, and everything works fine:

sudo fwconsole restart

How can I automate this? I tried doing this:

sudo crontab -e

…and then adding the following cron job:

@reboot fwconsole restart

However that did not work. I must do it manually. This is very frustrating

Any help would be much appreciated!

Also, the fwconsole restart command MUST start with sudo (root privileges), or it fails.

There are 3 users on the machine (“root” “asterisk” “ec2-user”)

I’m not sure if the command would still need root privileges if I could run commands as the user “asterisk”, but with Amazon AWS, you can only log into the command line as “ec2-user”, and not “asterisk”.

So, root permissions are necessary to run this command

How did you install Asterisk and FreePBX? All normal installation procedures, arrange for Asterisk to be started in the normal way for a daemon (“service” in Windows speak). Which distribution of Linux are you using?

It’s running on Amazon Linux 2, but I’m fine with just patching the problem, just so I don’t have to manually run this command if the system reboots.

I DO appreciate the help at trying to address the “root” of the problem (no pun intended), but I finally have built a NEW installation that works well on AWS, and I only really need help “patching” the problem, since everything else works fine.

I’ve spent days fixing something that wasn’t broken (because Amazon made everyone re-do their servers if they’re on old hardware), and at this point, this 1 line command that I must issue at reboot is the only problem not ironed out!!!

Amazon AWS installations are tricky to say the least, but I’m stuck with AWS because my IP address is with them, and that’s just too much to change providers

I went with Amazon AWS 11 years ago, because they were basically the only decent cloud computing platform. It took so many hoops to jump through to get it to work, but we did, and it’s been running fine for 11 years, but Amazon says the servers it’s running on are being retired, and there’s no way to migrate without starting fresh…. so I’m starting fresh on newer Amazon hardware

You didn’t answer the question, “how did you install your system?” expect to find a systemd ‘freepbx.service’ file that when enabled will either start fwconsole which will start asterisk (and either wait for or start other needed services) as dependancies, in it’s absence and you installed another way, then asterisk source provides an asterisk.service file that when enabled will at least start asterisk.

Where is that file located? I will check it

I didn’t install, because that’s almost impossible to do bug-free with Amazon’s flavor of Linux. (EC2 is a little different than cloud services like Vultr). Very few have succeed with EC2

Instead, I used 1 of the 2 public FreePBX machine images on Amazon AWS EC2.

The 2nd image was even worse. The machine would always crash after about 30 mins (FreePBX GUI and SSH command prompt would go down completely, but calls would still work)

It’s very difficult to get FreePBX fully functioning on AWS EC2, but I really don’t want to change my IP address

I have this same issue at Vultr with the ISO, standard distro. I reboot and it looks like Asterisk comes up but I still have to fwconsole restart to get it running. Annoying.

Then something else is going on. I have installed the distro on Vultr with zero issues.

You were right. This system had been upgraded from 14 to 15 and to 16. I rebuilt it from the 16 ISO, restored a backup and it starts up normally now on reboot.

Interesting development. I snapshotted my server at Vultr and moved it to a different location as I was having some packet loss. I have the same problem with Asterisk not starting properly on boot up. Worked fine before the snapshot and move. I guess I’ll need to rebuild it again to get it to start properly.

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