top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How do I automatically start a program at start up in Linux?

+6 votes
430 views

I have following requirement -
1. A graceful shutdown should run my stop script.
2. On boot I should able to start a program i.e. via script.
3. There should be a way to start and stop the program via script.

Any pointers.

posted Sep 18, 2013 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+2 votes

If you already have, put your scripts in /etc/rc.d/init.d. There's a standard set of parameters the scripts should take, e.g. "xyzscript start", "xyzscript stop".

Now, you need to make sure they're going to run. There are some predefined directories in /etc/rc.d called rc.0, rc.1, etc. "man init" for a full description. You will probably want to add your script to rc.local. So, do this.

ln -s /etc/rc.d/init.d/xyzscript /etc/rc.d/rc.local/99xyzscript

Now, the next time you reboot, your script will be automatically called with "xyzscript start", and when you shut down, it will be called with "xyzscript stop".

The scripts will be executed as root. you can su to another user when you execute a program inside the script.

answer Sep 18, 2013 by Satyabrata Mahapatra
Similar Questions
+2 votes

I am used to traditional update-rc.d et all.

Now I wonder how to add a a script that used to called by init.d (with start/sop ..) to the new "service start xx" regime.

All the tutorials I found talk about how to use update-rc.d..

+3 votes

When I configure my google test framework for a 32 bit machine, I can run all my test cases successfully with no unpredictable behavior. But when I configure it for a 64 bit machine & run my test cases, it gives severe & abrupt crashes. It crashes in places where it is not supposed to. I tried debugging the issue but was out of my depths. I am not sure if there is a problem while configuring the google test framework for 64 bit or maybe it does not support 64 bit. Any help would be appreciated. Please feel free to get in touch if any clarity is required regarding the query I have shared.
Note : The same code base works perfect on a 32 bit machine.

0 votes

I have an existing system which contains a LAN connected disk drive. I have added a new computer on which I installed Ubuntu (this is my first linux experience). From the Ubuntu computer I can read the files on the samba connected drive but I can not write to those files. I have tried to change the permissions but can not locate where the drive is mounted. So my question ishow do I change the permissions?

...