PDA

View Full Version : [ubuntu] Sessions on ubuntu server to have a script on the start up


any.linux12
February 23rd, 2009, 12:32 PM
Hi!

I need to put a script that I wrote in the start up, such that, if I have to restart the server it will execute the script alone.

I know that in desktop versions is in system -> preferences -> sessions, but in ubuntu server I have no idea

lykwydchykyn
February 23rd, 2009, 12:53 PM
Typically you'd put it in /etc/rc.local. Does it need to run as root or a specific user?

TurboRush
February 23rd, 2009, 01:59 PM
Do the following...

sudo cp /script/location/script_name /etc/init.d
sudo update-rc.d script_name defaults

Please note, this assumes its ok for the script to be run as root and using default run levels. Additionally, this script will get called on start up and shutdown so you may want to look at some basic examples of how to incorporate logic (if you haven't already), e.g.,


# MediaTomb auto-start
#
# description: Auto-starts MediaTomb
# processname: mediatomb

case $1 in
start)
echo Starting MediaTomb
mediatomb -i192.168.1.100 -d
;;
stop)
echo Stopping MediaTomb... doing nothing.

;;
restart)
echo Restarting MediaTomb
mediatomb -i192.168.1.100 -d
;;
esac
exit 0