Skip to content

Instantly share code, notes, and snippets.

@Mr-MaNia7
Last active February 18, 2024 16:03
Show Gist options
  • Save Mr-MaNia7/f9ffa74f33f665e614ac233b4a9bfaa2 to your computer and use it in GitHub Desktop.
Save Mr-MaNia7/f9ffa74f33f665e614ac233b4a9bfaa2 to your computer and use it in GitHub Desktop.
Solution for Database and Asterisk start order issue

Running a Command on Server Startup using Cron Job

Introduction

This guide explains how to execute a command using cron jobs every time the server starts or restarts on Ubuntu. It also covers how to mitigate the need for sudo in the cron job and ensure the command can run without requiring password input.

Prerequisites

  • Ubuntu server
  • Basic knowledge of using the command line

Instructions

Using sudo in .profile for fwconsole restart

You can add sudo to the command in your .profile file if the fwconsole restart command requires elevated privileges.

Here's how you can modify the command to include sudo:

sudo /usr/bin/fwconsole restart

Make sure that the user running the command has appropriate permissions in the sudoers file (/etc/sudoers) to execute fwconsole restart with sudo without being prompted for a password.

After adding the sudo prefix to the command, save the changes to your .profile file, and the fwconsole restart command will be executed with elevated privileges the next time you log in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment