Jump to content

Restart Script?


Recommended Posts

Hi, I've looked around and asked various people but I still clan't find a good way to make an auto-restart script for my server (Running ubuntu 12.04)

 

Does anyone know how to make one >_<?
 

 

Thanks.

Link to comment

found on ja+ mod files.

 

japlus_linux_autorestart.sh

 

#!/bin/bash


#  *********JA+ Linux server AutoRestart script*******************************
#  this is a secure startup file that uses the raven dedicated server pack for linux
#  if the server crashes, it will be immediatly restarted within 10s and the restart time will be writen to the file
#     japlus_restart.txt
#  
#
#  1)  install the raven dedicated server pack for linux (and the JAPLUS mod)
#  2)  and then put this file in your gamedata folder
#  3)  then execute this  file to start your server with JA+ mod (don't forget the chmod +x)
#
#  ****************************************


/bin/ps ux > ./.temp
alive=`grep -l 'linuxjampded' ./.temp | wc -l`;
     
if [ $alive -eq 0 ]
then
     
         lastrestart=`/bin/date`;
    echo "JA+ server restarted on $lastrestart" > ./japlus_restart.txt ;        
       

    nohup ./linuxjampded +set dedicated 2  +set fs_game japlus +exec server.cfg >log.txt 2>&1
             
          

        sleep 10;
        
        nohup ./start_japlus_linux_autoRestart.sh &
    
fi

Link to comment

...Because writing the entire process list to a file and grepping it every 10 seconds won't cause any issues

 

If you have the option to run it in a screen session, I would recommend something like:

#!/bin/bash

echo "Superleet startup script!"

status=1
while [ $status -ne 0 ]
do
        ./linuxjampded +set dedicated "2" +set fs_game "japlus" +exec "server.cfg" >log.txt 2>&1
        status=$?

        if [ $status -ne 0 ]
        then
                date=`/bin/date`
                echo "Server crashed with status "$status" at "$date
        fi
done

echo "Server exited peacefully"
Link to comment

 

...Because writing the entire process list to a file and grepping it every 10 seconds won't cause any issues

 

If you have the option to run it in a screen session, I would recommend something like:

#!/bin/bash

echo "Superleet startup script!"

status=1
while [ $status -ne 0 ]
do
        ./linuxjampded +set dedicated "2" +set fs_game "japlus" +exec "server.cfg" >log.txt 2>&1
        status=$?

        if [ $status -ne 0 ]
        then
                date=`/bin/date`
                echo "Server crashed with status "$status" at "$date
        fi
done

echo "Server exited peacefully"

This worked ^^ ty! 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...