You didn't mention your distro. For many distros and many Unix variants you create a startup script and put it into /etc/init.d. You then create a symbolic link to this script within /etc/rc?.d where the ? is replaced by the run level (0,1,2,3,4,S) you want it started and stopped at.
Such scripts have a specific format with functions at least for start and stop. You shold put the link for the stop at the run level below the start so that in a shutdown it stops.
Looking at existing scripts in /etc/init.d and the /etc/rc?.d links back to them will give you a good idea of how to build them. Note that links with name S##<scriptname> are start scripts and links with K##<scriptname> are stop scripts. ## is a number indicating in which order the script should run. Typically you make the number complimentary to 100 just for ease. (e.g. S25 start would be K75 stop.)
Note that often /etc/init.d itself may be a symbolic link to where your distro really wants to put the files.
|