Page 1 of 1

Howto automatic run/start a program at startup?

PostPosted: Apr 14th, '13, 06:03
by janpihlgren
I'm using Mageia 2 x86-64.
When I start the computer I whish to run a program automatic (no need to do any manual action).
I have found out that I have to put the command in one of the directory /etc/rc0.d - /etc/rc5.d.
rc6.d looks like to be used when shutdown the computer.
I think the commandname has to begin with Snumber. The command with the highest number will start last.
I have looked in both rc3.d and rc5.d.
In rc3.d, rc4.d and rc5.d there are a some commands that already start with S99.

First: Can I have my startcommand beginning with S99?
Second: In which directory?

Re: Howto automatic run/start a program at startup?

PostPosted: Apr 14th, '13, 08:18
by isadora
Would give it a try with:
System Settings->System Administration->Startup and Shutdown->Autostart->Add
Program...

Re: Howto automatic run/start a program at startup?

PostPosted: Apr 14th, '13, 10:08
by djennings
If you want a service to start at boot then you put a startup file in /etc/rc.d/init.d Do not touch files in /etc/rc.d/rc5.d or the other locations. They are maintained automatically by chkconfig.

If you look at the headers of files in /etc/rc.d/init.d you will see they all have a common format like this
Code: Select all
#!/bin/sh
#
# Startup script for dansguardian
#
# chkconfig: 345 92 8


This means it will run in run levels 3 (text only with networking), 4 (I forget what run level 4 is), and 5 (graphics with networking) It will start at position 92 (near the end), and shutdown at position 8.

Running the command
Code: Select all
chkconfig startupfilename on
will automatically cause copies of the file to appear in the correct directories
Code: Select all
chkconfig startupfilename off
will remove them again.

See 'man chkconfig'

As it happens you will see there is already a file called /etc/rc.d/rc.5/S99rc-local which is a symlink to /etc/rc-local
This file is there for you to modify to add any applications you want to start at boot time.

If you want an application to start as a user when they log in then put a .desktop file in /etc/xdg/autostart. (independent of which desktop you are using), or else use the method defined for your desktop.

Re: Howto automatic run/start a program at startup?

PostPosted: Apr 17th, '13, 21:21
by dedanna1029
Question: What do we do if we only want it to start up automatically for our own user, and use Gnome? Alacarte is not operational right now; it has a bug filed.

Re: Howto automatic run/start a program at startup?

PostPosted: Apr 18th, '13, 03:16
by r0b0tl0ve
You could always go old school and put it in your ~/.xsession.

Background each application like this:

Code: Select all
conky >/dev/null 2>&1 &

pidgin >/dev/null 2>&1 &



That way, one app won't hold up another from loading.

Re: Howto automatic run/start a program at startup?

PostPosted: Apr 18th, '13, 15:40
by dedanna1029
Thank you. :)

I'm wondering also if putting the .desktop file for the particular program desired to auto-startup in ~/.config/autostart/ would do it? I'm imagining not, as it currently contains .desktop files of proggies I used to have autostart, but are now disabled.

By ~/.xsession, I'm assuming you mean /.gnome-session, ~/.kde-session, etc.? I don't have a ~/.xsession file in the root of my /home.

Thanks again!

Cheers.

Re: Howto automatic run/start a program at startup?

PostPosted: Apr 18th, '13, 20:15
by martinw
Assuming you are using Mageia-2, in a terminal window type
Code: Select all
gnome-session-properties

and use the Add button in the Startup Programs tab.

Re: Howto automatic run/start a program at startup?

PostPosted: Apr 22nd, '13, 16:32
by dedanna1029
Ah, thanks. :) Had forgotten that one.