Jump to content

Automatic Restart Scripts Linux?


Kr0zer

Recommended Posts

Correct :)

 

If you get the "Can't find Binary" problem then this should fix it

cd / && /home/dayzservers/epochchernarus/restarter.pl

Changing the location to your files though :)

 

I've been trying to get this working for a few days now? Don't suppose you could come on teamspeak and help me sort this out please?! 

Link to comment
Share on other sites

It's not so difficult.

 

You execute the script restarter.pl at specific times given via linux cron job.

Therefore you open the cron editor with crontab -e (for my debian...maybe it's different for your distribution but it's easy to figure out with a search engine).

 

After executing crontab -e you see a text file with something like this:

# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command

m = minute, h = hour, dom = dayOfMonth, mon = month, dow = dayOfWeek, and command is the command to execute

 

For my restarter.pl I have this line in my crontab:

0 */4 * * * /home/epoch/server/restarter.pl >> /home/epoch/server/restart.log 2>&1

...which means: excute the script at the zero minute of the hour (0), all 4 hours (*/4). * * * means every day.

 

I execute /home/epoch/server/restarter.pl as the command as this is the place where my restarter.pl is located.

 

The rest (>> /home/epoch/server/restart.log 2>&1) is not needed...it just logs all messages (if there is output in restarter.pl) and errors the command outputs to a file restarter.log.

 

CTRL-O writes the changed file, CTRL-X leaves the crontab editor and you will see a message that your changes are now scheduled or something similar.

 

You need to decide when you want to execute restarter.pl and how often and edit the line accordingly.

 

That should be all.

 

I use an absolute path in the config section at the beginning of my restarter.pl so that cron finds the binary as cron does not execute the script (restarter.pl) from your server directory...but I guess from the server users home directory:

use constant PATH      => '/home/epoch/server/';

Of course you need to change the path to your settings in restarter.pl and the cron line above.

Link to comment
Share on other sites

Are you using  0.0.0.0  or the external ip in the config.php?  

i tried 127.0.0.1 and the external ip. ill try 0.0.0.0

 

EDIT: same deal with 0.0.0.0

 

testing with php ./resinf.php BTW

 

tried netstat -lnptu

udp        0      0 0.0.0.0:27015           0.0.0.0:*                           7060/epoch      
udp        0      0 0.0.0.0:27016           0.0.0.0:*                           7060/epoch      
udp        0      0 0.0.0.0:2302            0.0.0.0:*                           7060/epoch      
udp        0      0 0.0.0.0:2304            0.0.0.0:*                           7060/epoch

 

those ports are bound and forwarded. i tried changing steam query and steam ports to 27016 and 27015 so the configs are working

 

EDIT 2: found nifty command "nc -vu [external ip] 2302"

Connection to [external ip] 2302 port [udp/*] succeeded!

 

man im confused now. screw port checker though...

using: Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-43-generic x86_64) if that helps

 

BERcon cant connect either BTW

Link to comment
Share on other sites

im using BEC with wine and issue a #shutdown when the restart should happen

 

a simple perl script restarts the server anyhow if its away  therefore no need for complex scripts (if you just want a restart and nothing else)

 

* * * * * /path/to/perlscript.pl  for cron 

$a2pid = `/usr/bin/pgrep <ARMASERVERNAME>`;
if ($a2pid eq "")
{
  @do = `~/restart_server.sh`;
}

example restart.sh (in this case a wasteland server)

#/bin/bash

pkill -e arma3server
pkill -e Bec.exe
pkill -e wine


cd ~/
cd battleye
echo Starting BEC ...
screen -L -h 1024 -dmS bec wine-auto Bec.exe -f Config.cfg --dsc
cd ..
echo Starting A3 Wasteland Server
screen -L -h 1024 -dmS wasteland ./arma3server -mod="@extDB;" -config="wasteland.cfg" -port=2302 -world=empty -profile=Player -noSound -noPause -autoInit
sleep 5
echo Services up

dirty but working. Only exception is that its actually just working if there is only one instance of the armaserver running
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Discord

×
×
  • Create New...