Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Any prog exist to keep a server running?

Status
Not open for further replies.

ncc14113

Technical User
Mar 2, 2001
2
US
I am running a game server with Redhat 6.2, and I am worried about when it crashes. I can telnet in and restart it myself, but I can't monitor it 24hrs a day to do this. What I am looking for is a program to load it with on bootup that will restart the server if it should crash. I have looked for a while on the internet now, and haven't found anything. Thanks for your help.
 
This sounds like a good job for Perl... What you could do is write a perl program that pings the port occaiosanilly, like with a cron script, and if it's down, you can have the perl program telnet to the server and run the restart command. You may end up paying someone to write this for you, but it shouldn't be too difficult. If you're an admin, perl is actually good to know, so you may wanna use this as an excuse to learn it. and are good places to start! Good Luck, and I also am avalible for contract work...

MWB.

Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.
 
The simplest way is to run the program from a script which constantly loops. That way if the server crashes then the script simply loops and restarts it.
The best way to start programs on boot is by using the /etc/rc.d/init.d startup scripts. These scripts allow you to start different programs depending on the run-level of your server. E.g. Single user mode, X graphical login or text mode.
Read 'man init' for an overview of run-levels.

Example script =

#!/bin/sh
while 1
do
serverprogram
done
# end of script

and run the script thus
'nohup ./script &'
 
I think that the example script is bad because it is too busy... It will neverl sleep, and it will use up resources too much. If you're going to put a program locally on the machine, run it as a cron job.

#!/bin/sh
if(serverdown)do
restart
else
exit

somthing like that, and run it every so often with cron.

Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.
 
Are you worried about the game / program crashing or the server crashing ??

If you are worried about the game / programs crashing a script could be created to monitor its status. This could be done with very little overhead.
It could be done with perl or a simple shell script, korn, bash etc ..

If your worried about the server crashing there may not be a easy answer. As there are way to many varibles involved.

I would look at creating a script that monitors the ethernet port for a activity and possible the programs that seem to be mission critical.



-Danny






 
I'm a beginner with Linux but I think you can do this with "crontab"
 
Thanks for all the great info fellas, I looked into all your ideas.. right now I have been messing with inittab in /etc. I added this line to the bottom:

42:3:respawn:/etc/startgame

I then made a batch file called startgame in etc with the command line to run the game. This seems to start it on bootup, then respawns it if it terminates. So far it's doing ok, but I am still trying to figure out how to bring that to the foreground so I can input commands to the game.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top