[Help]Keeping the Server Online for linux
#1

hello! wish you could help me in the consule 'PuTTY' error.
PHP код:
root@PlayVirtualReality:~# cd samp
root@PlayVirtualReality:~/samp# cd samp03
root@PlayVirtualReality:~/samp/samp03# nohup ./restart.sh &
[127278
root
@PlayVirtualReality:~/samp/samp03# nohup: ignoring input and appending output to `nohup.out'
nohupfailed to run command `./restart.sh': Permission denied 
my code:
PHP код:
#!/bin/sh
log=samp.log
dat
=`date`
samp="/root/samp/samp03/samp03svr"
cd /root/samp/samp03
 
echo "${dat} watchdog script starting." >>${log}
while 
true; do
        echo 
"${dat} Server exited, restarting..." >>${log}
        
mv /root/samp/samp03/server_log.txt /root/samp/samp03/scriptfiles/Logs/server_log.`date '+%m%d%y%H%M%S'`
        ${
samp} >> $log
    sleep 2
done 
I am using method 2 of the link below.
https://sampwiki.blast.hk/wiki/Linux_Ser..._Server_Online
Reply
#2

That code looks pretty bad. Here's something I did a while ago:

This code will ensure that your server is restarted if it's down. (Save the file as: autorestart.sh)
PHP код:
#!/bin/sh
msampdir="/home/samp"
mprocess=`ps -C samp03svr | grep -v PID`
if [ ! 
"$mprocess]; then
    
echo "=- SA-MP server is not running. Restarting... -="
    
    
cd "$msampdir"
    
nohup ./samp03svr &
fi 
If you want to save logs, try this: (Save the file as: logrestarter.sh)
PHP код:
#!/bin/sh
logfile="/home/samp/server_log.txt"
timestamp=$(date --utc +%s)
thedate=$(date +"%B %d, %Y - %l:%M:%S")
logdir="/home/samp/server_logs"
if [ ! -"$logdir]
then
    mkdir 
"$logdir"
fi
cat 
"$logfile"$logdir"/Logs_Server_$timestamp.txt
echo "SAMP Logs refreshed at: $thedate"$logfile
In this case you will need to edit your crondtab file to the following:
PHP код:
SHELL=/bin/bash
PATH
=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO
=root
HOME
=/
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name command to be executed
  
*/* * * * samp /home/samp/autorestart.sh
  0 
*/12 * * * samp /home/samp/logrestarter.sh 
That will run a task every 1 minute and will check if your server is up and running. The other task will run every 12 hours and it will save your logs to the folder you chose.

After editing your crondtab file, run the following command in putty:

service crond restart

Just edit the paths to however you want it.

(Note; Make sure you chmod +x autorestart.sh, logrestarter.sh and server_log.txt)
Reply
#3

this is my difficulty in editing the file crondtab could help me.
Reply
#4

Quote:
Originally Posted by lucas_mdr1235
Посмотреть сообщение
this is my difficulty in editing the file crondtab could help me.
Use ******, there's tons of articles on it, no sense in someone spoon feeding you here.
Reply
#5

I managed to edit, but now I turn off the server through the RCON and serves no league, which will be the reason? I left the last blank line! how to test to see if the system is working? what command to turn off the system autorestart.sh?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)