Adding/Removing Shell scripts
Original Post From: StringOfThoughts
Adding a script
First of all write a script, say test.sh and put it in the directory /etc/init.d . Next we need to make it executable so.
$ sudo chmod +x test.sh
You can check if the script is working by issuing
$ sudo ./test.sh
Assuming the script is working as expected, to make the script run at startup / reboot.
$ sudo update-rc.d -f test.sh start 99 2 3 4 5 . // Run at startup $ sudo update-rc.d -f test.sh start 1 0 6 . // Run at reboot
Just a reminder there is dot (.) at the end of command. Don’t forget that!! Now you are done adding a script to run at startup.
Removing a script.
Just a reminder for new users, don’t just go to /etc/init.d and delete the script file
that wouldn’t help and may cause you trouble. We need a nice little application called rcconf (Debian runlevel configuration tool)
$ sudo apt-get install rcconf
then run rcconf (only root can run rcconf)
$ sudo rcconf
The interface is very simple. It lists the scripts so all you need to do is find out where is your script and toggle “*” using space bar and then select OK. That’s all. The script is now removed but still present in the directory /etc/init.d but you can safely delete it now.
Bonus: My shell script to launch JasperServer at start up:
#!/bin/sh /opt/jasperserver-3.1/jasperctl.sh start