Server auto-restart using cron - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Server (
https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (
https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: Server auto-restart using cron (
/showthread.php?tid=652439)
Server auto-restart using cron -
Obsidian - 11.04.2018
Hi,
I'm trying to make a server restart with cron since in case of something going wrong, I can restart the vm(vps) and the server will also restart. However, I used the info from WIKI and also from here
https://sampforum.blast.hk/showthread.php?tid=512383 (post no: #4) but nothing. I added the cron records as specified in the topic but still nothing.
Here are the screenshots and logs:
From the VPS crontab:
*/1 * * * * /home/sampserver/samp03/autorestart.sh >/dev/null 2>&1
@reboot /home/sampserver/samp03/autorestart.sh >/dev/null 2>&1
Screen with the path & directory of the script:
https://gyazo.com/176c893e8155eaf85c731fdd92dd6b1b
Script code:
Code:
#!/bin/sh
user=sampserver
serverlocation=/home/sampserver/samp03 #(same directory as samp03svr)
PROCESS_COUNT=$(ps -fu $user | grep samp03svr | grep -v grep | wc -l)
case $PROCESS_COUNT in
0) cd $serverlocation
nohup ./samp03svr >>nohup.out 2>&1 &
printf "PID:%s:" "$!"
;;
1) #OK, program is already running once
;;
*) #OK, program is already multiple times
;;
esac