How to make an application starting on boot?

Hello,

My app needs to start at boot. I can do that fine on Mac and Windows but I can’t find a way on Linux. I’ve tried with the xinitrc file, but that’s only for non-gui apps (mine is a gui one). I’m fine with a per-distribution solution, but even that seems impossible.
Even as an user point of view, this looks not doable; I hardly believe Linux doesn’t allow GUI apps to start at boot up. Am I missing something?

if that is so you can make an sh Script for your app (for example ‘myApp.sh’)

[quote]#!/bin/bash
cd /path/to/your/app/
./yourApp[/quote]

and make an entry in /etc/rc.local

Thanks. I tried that, including a piece of text gathered from the Internet, but it did not work. My /etc/rc.local file looks like this at the moment:

#!/bin/sh -e

rc.local

This script is executed at the end of each multiuser runlevel.

Make sure that the script will “exit 0” on success or any other

value on error.

In order to enable or disable this script just change the execution

bits.

By default this script does nothing

exec 2> /tmp/rc.local.log
exec 1>&2
set -x

/home/anic/Desktop/test.sh
exit 0

This creates a file in /tmp showing me what goes wrong (when something does go wrong). This is the content of that file:

  • /home/anic/Desktop/test.sh

(RemoteObserverServer:1079): Gtk-WARNING **: cannot open display:

According to some information I got from the Internet, the rc.local file executes before the GUI is even started; if this is true, maybe it would explain that it can’t open a display? I don’t know Linux enough to understand this area.

maybe you can try creating a desktop file for your app in ~/.config/autostart/

I found this in my notes:

Add a program to run at startup in Ubuntu Linux Server via the command line.

1. Login with root access.

Find the location of the program you wish to run at bootup.
For example, MyProgram is located in /home/me/programs/MyProgram

2. We need to create a script file in the init.d folder and we need superuser privileges for that.

2a. Run the command

sudo touch /etc/init.d/RunMyProgram

It’ll prompt you for the root password, enter it. Make sure the file has been created in that directory.

2b. Make the file executable.

sudo chmod +x /etc/init.d/RunMyprogram

3. Open that file in a text editor

nano /etc/init.d/RunMyProgram

4. We’re going to create a simple script that will simply call our program.

Type this bit of code in that text file. Replace the second line with the file path for your program. That is all that should be in the text file.

[code]#!/bin/bash

/home/me/programs/MyProgram &[/code]

4a. This script will automatically run as root.

If you want your program to run as a standard unprivileged user, put in a 'su ’ before the second line.

5. We need to assign our script to a certain runlevel (at what state in Linux’s bootup you wish to run the program).

5a. Simply run

sudo update-rc.d /etc/init.d/RunMyProgram defaults

and that will put you at the appropriate runlevels.

You can’t successfully run a GUI program at system boot because you don’t have a window manager session to run against. For example, almost all of our server system don’t even have X11 installed and start at init level 2 (non-GUI, but multi-user). Even if you are booting to run level 5 (X11), The XDM login screen is not truly a GUI environment. The Xsession doesn’t exist until a user logs in.

While you may be able to hack something for a specific Linux version by creating a hidden desktop user login, it won’t work for all Linux systems. If you want to have a daemon process like this, you will need to create a non-GUI version of your app.

I found this that seems to start at login instead of boot :
http://askubuntu.com/questions/30931/how-do-i-make-a-program-auto-start-every-time-i-log-in

[quote=284286:@Michel Bujardet]I found this that seems to start at login instead of boot :
http://askubuntu.com/questions/30931/how-do-i-make-a-program-auto-start-every-time-i-log-in[/quote]
Thank you. So it’s doable manually, that’s good to know. Unfortunately, it doesn’t suit my needs (the app should launch with whichever user logs in). I think I’ll consider Linux still lacks things and give up.

Is there a way to launch something after a user logs in? (like it’s doable in Mac and Windows)

It’s a dead end, then.
Thank you for your answer.

[quote=284235:@Oliver Osswald]sudo update-rc.d /etc/init.d/RunMyProgram defaults
and that will put you at the appropriate runlevels.[/quote]
I’m getting this output:
update-rc.d: /etc/init.d//etc/init.d/RunMyProgram: file does not exist
If I try without the “/etc/init/” part (since it seems to be assumed by default), I get a warning about missing LSB information, but it then adds system startup things. However, my app doesn’t start on boot.

I think Tim Jones is right: Linux lacks the ability to run a GUI app at startup.
Thank you for your answer.

That would work for a specific user only. I need it to run with any user (like a remote desktop application).
Thank you for your answer.