Software & AppsOperating SystemLinux

How To Automatically Start a Background Application on Boot in Ubuntu

Ubuntu 18

In this article, we will guide you through the process of automatically starting a background application on boot in Ubuntu. This can be particularly useful if you have certain applications or scripts that you want to run every time your system starts up.

Quick Answer

To automatically start a background application on boot in Ubuntu, you can use either the /etc/rc.local file, the Startup Applications utility, or create a custom script. These methods allow you to define the command for your application to start automatically when your system boots up.

What You Will Need

Before we start, make sure you have the following:

  • A computer running Ubuntu.
  • The application or script you want to automatically start on boot.
  • Administrator access to the system.

Method 1: Using /etc/rc.local

One of the traditional ways to automatically start applications or run scripts at boot time in Ubuntu is by using the /etc/rc.local file. This file is a script which is executed by the system as the last step during the boot process.

Step 1: Open /etc/rc.local

Open a terminal by pressing Ctrl + Alt + T and type the following command:

sudo nano /etc/rc.local

This command uses sudo to run the nano text editor with root privileges, and opens the /etc/rc.local file.

Step 2: Add Your Command

In the opened file, add the command to start your application before the exit 0 line. For example, if you want to start a web server application located at /usr/sbin/archttp64 on port 81, you would add the following line:

/usr/sbin/archttp64 81 &

The & at the end of the command is used to run the process in the background.

Step 3: Save and Exit

Save the file by pressing Ctrl + X, then Y, and finally Enter.

Step 4: Test Your Changes

Reboot your machine to test if the script is working. After the reboot, your application should start automatically.

Method 2: Using Startup Applications

Another way to automatically start applications in Ubuntu is by using the Startup Applications utility. This utility allows you to manage applications that start automatically at login.

Step 1: Open Startup Applications

Open the “Startup Applications” program. You can find it by searching for it in the Ubuntu Dash.

Step 2: Add a New Startup Application

Click on the “Add” button to create a new startup program. In the “Name” field, enter a descriptive name. In the “Command” field, enter the command to start your application.

Step 3: Save and Exit

Click “Add” to save the startup program.

Step 4: Test Your Changes

Reboot your machine to test if the script is working. After the reboot, your application should start automatically.

Method 3: Using a Custom Script

If neither of the above methods work, you can try creating a custom script and adding it to your startup applications.

Step 1: Create a Custom Script

Create a new file in the /usr/local/bin/ directory and add your command to it. For example, you could create a file called MyScript.sh with the following content:

#!/bin/sh
/usr/sbin/archttp64 81

Step 2: Make the Script Executable

Make the script executable by running the following command:

sudo chmod +x /usr/local/bin/MyScript.sh

Step 3: Add the Script to Startup Applications

Follow the steps for adding a startup program mentioned in Method 2, but use /usr/local/bin/MyScript.sh as the command.

Step 4: Test Your Changes

Reboot your machine to test if the script is working. After the reboot, your application should start automatically.

Conclusion

In this article, we have covered three methods to automatically start a background application on boot in Ubuntu. Depending on your specific needs and the nature of the application you want to start, one of these methods should suit your needs. Remember to always test your changes to ensure that your application starts as expected.

Can I use these methods to start any application on boot in Ubuntu?

Yes, you can use these methods to start any application or script on boot in Ubuntu.

Do I need administrator access to use these methods?

Yes, you need administrator access to modify system files and use the Startup Applications utility.

Can I use Method 1 and Method 2 together to start multiple applications on boot?

Yes, you can use both Method 1 and Method 2 together to start multiple applications on boot. Simply add multiple commands in the /etc/rc.local file or create multiple startup programs in the Startup Applications utility.

Can I use these methods in other Ubuntu-based distributions?

Yes, these methods should work in other Ubuntu-based distributions as well.

How can I remove a startup program that I added using the Startup Applications utility?

Open the Startup Applications utility, select the program you want to remove, and click on the "Remove" button.

Can I use these methods to start applications for specific users only?

Yes, you can use these methods to start applications for specific users by modifying the respective user’s startup files instead of the system-wide files.

Will the applications start even if I’m not logged in?

Yes, the applications started using these methods will run in the background even if you are not logged in. They will start when the system boots up.

Can I use these methods to start graphical applications?

Yes, you can use these methods to start graphical applications. Just make sure the command you add is correct and includes any necessary arguments or flags.

How can I troubleshoot if my application is not starting automatically?

First, check if the command you added is correct. Make sure the path to the application or script is accurate. You can also check the system logs for any error messages related to the startup process.

Can I use these methods to start applications on a specific time schedule?

No, these methods are for starting applications on boot only. If you want to start applications on a specific time schedule, you may need to use other tools like cron or systemd timers.

Leave a Comment

Your email address will not be published. Required fields are marked *