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

I have a shell scrip that runs on jvm, it works as I write: sh /opt/bin/ I added a shell script to /etc/inti.d with this detail:

#! /bin/sh
# Provides:
# Required-Start:    $local_fs
# Required-Stop:     $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.


I saved this file as "" in "/etc/init.d" and change it's mode to executable. And also I used sudo update-rc.d defaults to update the "rc*.d" files. The problem is that it is not running on the reboot.

share|improve this question

migrated from May 27 '13 at 0:54

This question came from our site for professional and enthusiast programmers.

up vote 1 down vote accepted

The easiest way to have something executed on boot is putting it in /etc/rc.local. If you want to write a full Sys V init script, you probably want to use on of the existing scripts as template. You might also want to consider using an upstart job.

share|improve this answer
I totally can not understand what you are saying i'm a real naive! – Reza Ameri May 25 '13 at 9:37
Add /opt/bin/ to /etc/rc.local and see if it gets executed upon reboot. – TeTeT May 25 '13 at 12:48
@RezaAmeri: Nope. Just add a line at the end of the rc.local script to call your scipt (/opt/bin/ – TrueY May 26 '13 at 7:27
@TrueY you mean after exit 0? Or after comments and before exit 0? Or may be I have to remove exit 0 and add /opt/bin/ Thanks for help. – Reza Ameri May 26 '13 at 7:46
@RezaAmeri: I do not have the exit 0, but of course before it. – TrueY May 26 '13 at 8:54

At first check /etc/inittab file. There is a line like id:2:initdefault So it will start at runlevel 2 (in my case). So this will start at boot: /etc/init.d/rc 2. So all scripts starting S##somename (# is a decimal digit) in /etc/rc2.d will be run. These are symbolic links to the scripts in /etc/init.d.

So similar has to be done in your case. If your runlevel is 2 then create a symlink in /etc/rc2.d/ to the script in ../init.d/ Then it will run during boot. Keep in mind the scripts having the same script level (the two decimal digit after S) run parallel.

I would suggest you to check the files in /etc/init.d how they should look like, what arguments should be supported.

share|improve this answer
That's what update-rc.d [name] defaults does – glenn jackman May 25 '13 at 17:58
@glennjackman: I did not know that. Thx! – TrueY May 25 '13 at 18:58
My problem is exactly the skeleton of files in init.d I want to create a file in init.d that runs my shell and has the standard skeleton. – Reza Ameri May 26 '13 at 6:37

You must log in to answer this question.

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