LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   newb help (https://www.linuxquestions.org/questions/linux-newbie-8/newb-help-46582/)

DylanBlitz 02-21-2003 07:50 PM

newb help
 
I am setting up a gaming server and I wanted to set it up so that if the game isn't running it will start it, wether it's from a reboot or the service died or whatnot. Would a cron job be the best thing for that? And if it is, what would I do? have the cron job run a script that checks the service? if that's the best bet then can someone please point me to a good tutorial for scripts because I have no clue how to write one.

Crunch 02-22-2003 12:28 AM

First off i'm thinking you should elaborate more on your information (heh i do the same thing when i'm trying to explain something ) sort details aren't the key.. what kind of script are you looking for ? If you need a tutorial there are all sorts over the web, we need to know what kind of script you want to write anyway. So if you help us out by giving us the spoon we will feed you with that spoon (but first hold up your end and at least try looking for the correct script language you would want to use)

;]

DylanBlitz 02-22-2003 12:38 AM

hmm, not sure what kind of language I'd need to use. What I am doing is going to be running a dedicated battlefield 1942 server on a redhat 7.3 server hosted remotely. So that I don't have to login to shell and start the game up every time it goes down I wanted to make a script that would check and make sure an instance of the executable is running. Then run a cron job to execute the script. If you need any other info let me know, not sure what else you would need.
I was told that a cron job would do it itself but from what I found on the web cron just executes a command and I don't want the server restarted every 5 minutes, just want to check and see if it's running heh.

Thanks for the help and comments btw :)

Crunch 02-22-2003 01:14 AM

Well I'm only 15, and I at the moment know nothing about using / setting up servers, i tried some research for you but nothing got accomplished i only found stuff on how to setup a http apache server :( Sorry If i find anything i'll try and contact you :]

cuckoopint 02-22-2003 01:23 AM

assuming this runs as 1 program, and does not fork: maybe something like this will work:

Code:

a=`ps aux|grep program | grep -v "grep program"| wc -l`
this is really primitive, but it may give you an idea. this will give you a number of things running as "program". then you can do an if then statement: if greater than/equal 1 (ie. program running) return w/o error, but if not greater than/equal 1 (ie. program not running) then start program and log error.

hope this gives you an idea. This could easily be done in bash with the above code and an if/statement. Again, this is fairly primitive but may get the job done: you would just put the script in crontab to run every 15 minutes or something.

mhearn 02-22-2003 08:20 AM

Check out daemontools

We use this on the theoretic.com server to keep the jabber servers running. If one goes down it'll be restarted, if it freezes just do a killall and it'll be restarted.

It can take a bit of work to setup though

Crunch 02-22-2003 12:51 PM

Thanks for getting my back guys 8) I didn't know what to say really, I never planned on setting up a gaming server on linux :O but now i know what to do... Sorta.. lol


All times are GMT -5. The time now is 09:17 PM.