How to get a program to start at boot


Summary

This is just my notes on how to get a program to start every time your Linux box reboots.

While it looks complicated, it is pretty easy after you've done it once or twice.

This is what works for me on the current distribution of Debian Linux (Woody). Your mileage may vary.


Detail

  1. Create a script in /etc/init.d with the name of the program you want to start. The script looks like:

    
    		#!/bin/bash
    		#
    		# mydns startup script
    		#
    		#
    		RETVAL=$?
    		case "$1" in
    		 start)
    				echo "Starting MyDNS..."
    				mydns --background
    				;;
    
    		 stop)
    				echo "Stopping MyDNS..."
    				kill $(cat /var/run/mydns.pid)
    				rm /var/run/mydns.pid
    				;;
    
    		 *)
    				echo $0 "{start|stop}"
    
    		esac
    

  2. Make it executable:

    chmod +x mybootprog

  3. Create symbolic links to it in /etc/rc2.d through /etc/rc3.d:

    ln -s ../init.d/mybootprog S90mybootprog