07.09.2010, 16:09
Code:
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.
Code:
[1] 1771 [root@vps***** samp03]# nohup: appending output to `nohup.out' nohup: cannot run command `./restart.sh': Permission denied