Answer the question
In order to leave comments, you need to log in
Script-auto-lifter of the fallen server. Bash, screen, and other joys
Situation:
There is a Java server that crashes from time to time (because it sometimes runs out of memory on the VDS), but generally performs its task. There is a script that I'm trying to check if the server is running, and if it doesn't work, run it.
#!/bin/bash
echo "Server auto up script, Ctrl+C to stop keeping server up.";
while true
do
sleep 3
ps cax | grep java > /dev/null
if [ $? = "1" ]
then
echo 'Server restarting right now!'
screen -dmS Server "java -jar /path/to/server.jar -Xmx512M -Xms64M -server"
fi
done
java -jar /path/to/server.jar -Xmx512M -Xms64M -server &
screen -dmS Server "sleep 30"
screen -dmS Server "sleep 30 && echo CLUSTERFUCK"
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question