• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

n00b alert : How to start a program automatically in bootup??

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

baqai

Member
Joined
Sep 30, 2002
Location
Karachi, Pakistan
Okay i am kinda stuck here, i managed to setup a dedicated linux based quake 3 server and everything is working beautifully (just need to find a quake 3 linux based stats program) now i am stuck, i want that when ever machine reboots server automatically starts

here is what i have done

server is installed in

/usr/local/games/quake3/

in that directory i have a batch file (yeah lame of me but just shifted to linux so still have DOS habbits) by name of q3d.bat so i execute it by ./q3d.bat in the batch file i have defined q3ded +dedicated 1 ....... etc ..

what i did was in /etc/rc.d/rc.local i define

/usr/local/games/quake3/q3d.bat

that didn't worked for me so i tried

/usr/local/games/quake3/./q3d.bat

that didn't worked for me as well :(

what should i do ? and where am i making a mistake?
 
First I assume you have made the batch file executable. If in fact, the server starts with ./q3d.bat at a command prompt, i guess that it is. I'm not an expert, but I usually do this by making a very simple shell script using a text editor.
For this it would be:

#!/bin/bash
q3d.bat

Then save as any name you want. After that, I just put this file in the user "Autostart" directory of my KDE desktop. Here again, I have to assume you are booting into KDE. Some more details like which distribution and desktop you use would be helpful.
 
Just make a symlink to q3a.bat in /etc/rc3.d. Something like ln -s /usr/local/games/quake3/q3d.bat /etc/rc3.d/S99q3d should do the trick. I'm not sure of Slackware's init sciprts, so if /etc/rc3.d doesn't exist, don't make it.
If you don't manually stop the server, make sure to do ln -s /usr/local/games/quake3/q3dSTOP.bat /etc/rc0.d/K99q3d and ln -s /usr/local/games/quake3/q3dSTOP.bat /etc/rc6.d/K99q3d (where q3dSTOP.bat stops the server) so that the server will exit gracefully.
For consistancy, the scripts that start and stop the q3a server should be in /etc/init.d with all the other scripts. If you do that, change the symlinks accordingly.

In case you want to know what you're doing...
Anything in /etc/rc*.d should be a symlink that tells a certain service to start of stop for a given runlevel. (Look at /etc/inittab to see what the different runlevels are.) A symlink that starts with S should start a service and one that ends in K should stop it. The number tells what order to stop and start the services in.
 
i am running Red Hat 9 and i do have rc.3 on my system

so i am going to make a symb link of the batch file which will start the server automatically everytime the machine starts by

ln -s /usr/local/games/quake3/q3d.bat /etc/rc3.d/S99q3d

i am slightly confused about the q3dSTOP.bat file since i don't have that file .. if i create the file what should i put in it? since the dedicated server stops by command "QUIT" ??
 
For redhat, adding a line in /etc/rc.local also works well.

something like-

su -c "/usr/local/games/q3d.bat" username

Where username ia a regualr user who has proper permission to run the app. I don't usually recommend running any net-based app as root.

To make a script to shut it down,

Make a textfile like so:

#!/bin/sh
killall -15 process_name

Where process_name is the same name as the process you want to kill, probably q3d.bat in this case.

Save the file, make it executable to all, and stick it in /bin or maybe /usr/local/bin, where it's less crowded, and since its right next door in the file tree to usr/local/games and so easy to remember.

Then whatever you named the script will be useable as a command to close your program.
 
Last edited:
Back