How to execute a shell script on startup?

Posted by vijay.shad on Super User See other posts from Super User or by vijay.shad
Published on 2010-03-31T15:13:35Z Indexed on 2010/03/31 15:23 UTC
Read the original article Hit count: 422

Filed under:
|
|

I have create a script to start a server(my first question). Now I want it to run on the system boot and start the defined server. What should I do to get this done?

My findings tell me put this file in /etc/init.d location and it will execute when the system will boot. But I am not able to understand how the first argument on the startup will be start? Is this predefined somewhere to use start as $1? If I want to have a case startall that will start all the servers in the script, then what are the options I can manage.

My Script is like this:

#!/bin/bash

case "$1" in
start)
     start
    ;;
stop)
    stop
    ;;

restart)
    $0 stop
    $0 start
    ;;
*)
    echo "usage: $0 (start|stop|restart)"
;;
esac

© Super User or respective owner

Related posts about shell-script

Related posts about linux