You are doing 3 things wrong that I see.
First: You want to put your soft link in /etc/rcS.d/
to have it run when the machine enters "single user" mode (no networking available), and in /etc/rc[2-5].d/
to have it run when the machine enters "multi user" mode (Runlevels 2 thru 5). Runlevel 0 /etc/rc0.d/
is only entered when the machine is told to shutdown. Runlevel 6 is used for "Reboot". See the wikipedia page for UNIX Runlevels
Second: The name of the softlink cannot be collection.sh
. It needs to be of the form S09collection
where "S" means Start and "09" means Start after all of the 08 scripts have been started. See here for more details.
Third: init is used for starting daemon services, and should not be used to run collection.sh directly. You need to create an actual init script that handles the starting and stopping of the the collection.sh daemon. Study the pre-existing init scripts in /etc/init.d/
to get a feel for how they work. Alternatively have a look at the following links for more documentation on writing init scripts.
- Here is a how to on writing LSB compliant init scripts. This is recommened for LSB compliant Linux Distributions. I noticed you tagged your question with "ubuntu", so I should mention that Ubuntu (like all Debian based distros) is LSB compliant.
- Here is the Debian wiki guide on making init scripts LSB compliant.
- Here is a "Quick and Dirty" how to on System V style init scripts.
- Here is a template for a System V style init script on Github.
Also, you don't need to create the symbolic links directly in the /etc/rc?.d
folders. The major distributions all have automated tools for doing that. See this article for more details.