You are not logged in.
Pages: 1
I host a few different servers on a spare PC of mine, but sometimes they have a habbit to crash and I am not always home to bring them back online, I need a simple tool just to do that, but I want it to have restrictions so onyl certain commands can be ran, for example the starting of the servers command, ect. This is so another admin of one of my servers can bring it back up also.
Offline
what kind of services? it's probably not normal for them to be crashing like that.
Offline
Mainly a few game servers, during certain map changes, and other random things going on they do crash from time to time, and it's nice not to have to be called up early in the morning to start the servers
Offline
You should try and find a script that checks if the server is running and if not starts it. Place that script as a cron job for automatical restart whenever the script is run and finds out that the server isn't running.
Using pgrep you could easily see if the process is running or not, I think it should be pretty easy to create a script that checks if pgrep returns nothing and then starts the server.
EDIT: Did some googleing (I'm not specially good at bash scripting) and this simple script should get the work done (using thunderbird for showing how it works):
#!/bin/bash
if ps ax | grep -v grep | grep thunderbird > /dev/null; then
echo "Thunderbird is running, not starting it"
else
echo "Thunderbird is not running, starting it up"
thunderbird &
fi
PC: Antec P182B | Asus P8Z77-V PRO | Intel i5 3570k | 16GB DDR3 | GeForce 450GTS | 4TB HDD | Pioneer BDR-207D | Asus Xonar DX | Altec Lansing CS21 | Eizo EV2736W-BK | Arch Linux x86_64
HTPC: Antec NSK2480 | ASUS M3A78-EM (AMD 780G) | AMD Athlon X3 425 | 8GB DDR2 | GeForce G210 | 2TB HDD | Arch Linux x86_64
Server: Raspberry Pi (model B) | 512MB RAM | 750GB HDD | Arch Linux ARM
Offline
i guess you could write a script that checked to see if the programs are running, and then started them if they weren't. you could make it a cron job to run every minute or so, or however long you wanted between checks. i don't know advanced shell scripting, but it doesn't seem like it would be that hard. something that checked the output of ps ax and then started what wasn't running would probably be one way to do it.
Offline
[vEX] beat me.
Offline
I'm not sure how could that script works, there is "if pgrep PROCESS" but it kept reporting that the process wasn't running for me even though it was.
slashhack
PC: Antec P182B | Asus P8Z77-V PRO | Intel i5 3570k | 16GB DDR3 | GeForce 450GTS | 4TB HDD | Pioneer BDR-207D | Asus Xonar DX | Altec Lansing CS21 | Eizo EV2736W-BK | Arch Linux x86_64
HTPC: Antec NSK2480 | ASUS M3A78-EM (AMD 780G) | AMD Athlon X3 425 | 8GB DDR2 | GeForce G210 | 2TB HDD | Arch Linux x86_64
Server: Raspberry Pi (model B) | 512MB RAM | 750GB HDD | Arch Linux ARM
Offline
Here, this should do it:
#!/bin/bash
function runOnce(){
INSTANCE=`ps -A | grep -c program_name`
if [ "$INSTANCE" == 0 ]; then
program_name
else
:
fi
}
runOnce
This code just makes sure that an instance of program_name is running if it is not it starts it, otherwise, it does nothing.
You could use a cron job (say every 10 min') to "monitor" that the game server is running.
Hope this helps.
Offline
Thanks for the ideas everyone, problem solved. Thanks for the script ralvez, works like a charm .I still want to use some remote administation software of some sort, so I am also checking into Webmin so other admins can edit th servers config files ect, but as for the server crashing, this brings it back up automatically.:) On a side note, does anyone know of any good simple remote administation programs? Command line ones would be a plus for me, and access through telnet would be nice . But any remote administration applications are nice.
Offline
don't you have ssh? (openssh?) your cohorts could just log in at the command line and start whatever they needed to (with right permissions, etc.).
edit:
http://wiki.archlinux.org/index.php/Using_SSHD_and_SSH
http://wiki.archlinux.org/index.php/Using_SSH_Keys
Offline
You can use ssh and sudo.
The first to safely allow log in for your co-admins and the second to control what commands they are allowed to issue, that would take care of the problem.
R
Offline
Yup, don't even think choosing telnet over ssh!
Offline
Pages: 1