linux auto restart -
VIP475 - 05.04.2014
Method 2
If you don't want to use crontab and if you want to have server log saved to a separate directory on server crash you can use this script.
To keep your server online using this script, first you need to stop your server and then execute it with this command:
nohup ./restart.sh &
restart.sh:
Код:
#!/bin/sh
log=samp.log
dat=`date`
samp="/path/to/samp/server/samp03svr"
cd /path/to/samp/server
echo "${dat} watchdog script starting." >>${log}
while true; do
echo "${dat} Server exited, restarting..." >>${log}
mv /path/to/samp/server/server_log.txt /path/to/samp/server/logs/server_log.`date '+%m%d%y%H%M%S'`
${samp} >> $log
sleep 2
done
This method will bring your server back up whenever it crashes or when the RCON exit command is issued. It will also save the server log into a separate directory.
Where to put restart.sh ? in samp folder? or where? and i got samp in cd/root/samp03/ , can someone edit this for me please?
Re: linux auto restart -
Tamer - 05.04.2014
Код:
#!/bin/bash
log=samp.log
dat=`date`
samp="/root/samp03/samp03svr"
cd /root/samp03/
echo "${dat} watchdog script starting." >>${log}
while true; do
echo "${dat} Server exited, restarting..." >>${log}
mv /root/samp03/server_log.txt /root/samp03/logs/server_log.`date '+%m%d%y%H%M%S'`
${samp} >> $log
sleep 2
done
If your samp server executable is not samp03svr, then rename it to whatever you have.
Re: linux auto restart -
VIP475 - 05.04.2014
Thanks but where to put file restart.sh ..
Re: linux auto restart -
Tamer - 05.04.2014
Quote:
Originally Posted by VIP475
Thanks but where to put file restart.sh ..
|
Throw it to the same directory with samp03svr.
Re: linux auto restart -
VIP475 - 05.04.2014
nvm---
Re: linux auto restart -
VIP475 - 05.04.2014
alright
im using
Код:
#!/bin/bash
log=restarter.log
dat=`date`
samp="/home/samp03/samp03svr"
cd /home/samp03/
echo "${dat} Restarter script started." >>${log}
while true; do
echo "${dat} Server exited, trying to restart..." >>${log}
[ ! -d logs ] && mkdir -m777 -p logs
mv server_log.txt logs/server_log.`date '+%d.%m.%y.%H-%M'`.txt
${samp} >> $log
sleep 2
done
If i do /rcon exit, it restarts server. Im using centos 6 64 bit. If i go on solus vm panel, click REBOOT , or STOP , then START, it will NOT start the server automatically...
Is there any way to start it automatically when i stop vps, and then if i start it again?
Re: linux auto restart -
VIP475 - 05.04.2014
so...
how can i auto start samp server like chkconfig samp03svr

?? on centos 6 64 bit ?
i explained.. if i stop server on solus vm control panel, then click boot or reboot, it will NOT start automatically....
Re: linux auto restart -
bpsamp - 05.04.2014
all you gotta do is change this:
samp="/home/samp03/samp03svr"
cd /home/samp03/
to the directory where your samp03 folder is.
then you type nohup ./restart.sh &
your server will be kept online even if it crashes.
As for you boot, doesn't make any sense unless it's home hosted.
Re: linux auto restart -
VIP475 - 05.04.2014
what..
1. i go in solus vm panel, click reboot, or start, so it SHOULD start automatically samp server, thats what i want..
so i dont have to login to putty and start it with cmds...