Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
Programs on startup in Linux

I have a Linux machine running a program constantly, if power is cut out, the program wont restart until i open an SSH session and type in "./" This is just in case i lose power to the machine, and i want the program to automatically start on start up.


share|improve this question

marked as duplicate by studiohack Jan 16 '13 at 6:16

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

What version of OS are you using?

Depending on what it is you have essentially 2 options:


You can either add the executable to the rc.local file which is located here on Redhat distros: /etc/rc.local. You can simply add ./ to the end of this file.


If you want it to be a service then you'll need to add a script similar to the ones in /etc/init.d/. Again on Redhat based distros there is a tool to help manage these scripts called chkconfig. See the man-page for more info and also look at the other scripts in /etc/init.d for ideas on how to approach this.

Here's a sample to get you started:

#! /bin/sh
# Basic support for IRIX style chkconfig
# chkconfig: 235 98 55
# description: Manages the services you are controlling with the chkconfig command

case "$1" in
        echo -n "Starting new-service"
        #To run it as root:
        #Or to run it as some other user:
        /bin/su - username -c /path/to/command/to/start/new-service
        echo "."
        echo -n "Stopping new-service"
        #To run it as root:
        #Or to run it as some other user:
        /bin/su - username -c /path/to/command/to/stop/new-service
        echo "."

        echo "Usage: /sbin/service new-service {start|stop}"
        exit 1

exit 0
share|improve this answer

With a raspberry-pi, the simplest way would be to add a line with the full path of your script to the /etc/rc.local file.

share|improve this answer
When i search for the folder /etc/rc.local all i find are folders named rc0.d rc1.d rc2.d and so on... – user190333 Jan 16 '13 at 23:14
As I wrote, /etc/rc.local is not a folder but a file. If it doesn't exist, you should just be able to create it. – jlliagre Jan 17 '13 at 9:51

Not the answer you're looking for? Browse other questions tagged .