diracsbracket
Posts: 13
Joined: Thu Jun 25, 2015 3:07 pm

init.d script does not start after boot completes

Thu May 26, 2016 8:20 am

Hi,
I am learning to use boot scripts.
I created one using the following LSB header:

Code: Select all

### BEGIN INIT INFO
# Provides:          testscript
# Required-Start:    $all
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Simple script to start a program at boot
# Description:       A simple script
### END INIT INFO
After changing the permissions (chmod 775), I can start/stop it manually, and works correctly since it lauches my
application.

Code: Select all

sudo /etc/init.d/testscript start
sudo /etc/init.d/testscript stop
Then I did:

Code: Select all

sudo update-rc.d testscript defaults
And also tried (after the above did not work)

Code: Select all

sudo insserv testscript
However, upon reboot, my program does not start!

Can anyone tell me what I am doing wrong?

Thanks!!

diracsbracket
Posts: 13
Joined: Thu Jun 25, 2015 3:07 pm

Re: init.d script does not start after boot completes

Thu May 26, 2016 9:06 am

I turns out I forgot to add the shebang line to the top of my script file:

Code: Select all

#!/bin/bash
# /etc/init.d/testscript

### BEGIN INIT INFO
# Provides:          testscript
# Required-Start:    $all
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Simple script to start a program at boot
# Description:       A simple script
### END INIT INFO
The shebang line is needed since otherwise the system will try to execute this script as a program because my script filename does not have a .sh extension.

Return to “Beginners”