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

#! /bin/sh
# Provides:          WSO2Services.sh
# 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 "myShell.sh" in "/etc/init.d" and change it's mode to executable. And also I used sudo update-rc.d myShell.sh defaults to update the "rc*.d" files. The problem is that it is not running on the reboot.

2 Answers 2


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.

  • I totally can not understand what you are saying i'm a real naive!
    – Reza Ameri
    May 25, 2013 at 9:37
  • 2
    Add /opt/bin/myshel.sh to /etc/rc.local and see if it gets executed upon reboot.
    – TeTeT
    May 25, 2013 at 12:48
  • 1
    @RezaAmeri: Nope. Just add a line at the end of the rc.local script to call your scipt (/opt/bin/myshell.sh).
    – TrueY
    May 26, 2013 at 7:27
  • 1
    @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/myshell.sh? Thanks for help.
    – Reza Ameri
    May 26, 2013 at 7:46
  • 1
    @RezaAmeri: I do not have the exit 0, but of course before it.
    – TrueY
    May 26, 2013 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/S##myshell.sh to the script in ../init.d/myshel.sh. 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.

  • 2
    That's what update-rc.d [name] defaults does May 25, 2013 at 17:58
  • @glennjackman: I did not know that. Thx!
    – TrueY
    May 25, 2013 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, 2013 at 6:37

You must log in to answer this question.

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