SA-MP Forums

Go Back   SA-MP Forums > SA-MP Server > Server Support

Reply
 
Thread Tools Display Modes
Old 11/04/2018, 11:07 AM   #1
Obsidian
Little Clucker
 
Join Date: Jan 2018
Posts: 5
Reputation: 0
Default Server auto-restart using cron

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 http://forum.sa-mp.com/showthread.php?t=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
Obsidian is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Tool/Web/Other] Auto Restart server - Anti-Crash manojl Lançamentos/Releases 4 28/07/2015 01:17 PM
How can i make an auto-restart in my server? cleanboy Scripting Help 3 03/05/2014 08:57 AM
Server linux after crash auto restart. Aloushi Server Support 4 26/02/2014 04:31 PM
Server Auto-Restart Problem vitalz0r Server Support 1 14/08/2012 06:03 PM
Server Auto-Restart cotyzor Help Archive 2 16/06/2011 12:29 AM


All times are GMT. The time now is 06:54 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.