Jump to content
  • 0

Automatic Server Restart, Help!


LostKaus

Question

So I am nearly done setting up my server, all i need to have in it to finish is some sort of automatic restart script. I've looked around and I can't figure out what to use. 

I'm hosting my own server so any direction or help is greatly appreciated! 

It's Epoch 1.0.6

I'm fairly new to this coding stuff so the easier it is the better. I just don't know where to start

Thanks!

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

I do it like this.

You need BEC installed for the scheduler and then make 3  .bat files.

First called Server_Restart.bat

 

@echo off
echo.
echo KILL arma2oaserver.exe
set serverkill="YOUR SERVER ROOT PATH"
cd /d %serverkill%
taskkill /im arma2oaserver.exe
echo.
echo Kill Bec.exe
set beckill="YOUR BEC PATH"
cd /d %beckill%
taskkill /im bec.exe

timeout 5

echo.
echo Rotate Logs
start "start" "ROTATE LOGS .BAT PATH" 

timeout 5


echo.
echo Starting Dayz Server
:: start the server..
set dayzpath="YOUR ROOT PATH\"
cd /d %dayzpath%
start "start" "Server_Start_New.bat"
echo.
echo Starting Bec
timeout 20
:: start bec
set becpath="YOUR BEC PATH"
cd /d %becpath%
start "start" "bec.exe" -f Config.cfg
echo.
echo Server Started 100%

cls
@exit

 

second called Server_Start_New.bat

timeout 5

::Start Dayz Server::

start "arma2" /HIGH /affinity 2  "arma2oaserver.exe" -ip=xx.xx.xxx.xx -port=xxxx -maxmem=2047 -noPause "-config=instance_11_Chernarus\config.cfg" "-cfg=instance_11_Chernarus\basic.cfg" "-profiles=instance_11_Chernarus" -name=instance_11_Chernarus "-mod=@DayZ_Epoch;@DayZ_Epoch_Server;"

cls

@exit

 

Third called rotate_logs.bat, this isnt necesary if you dont want it though.

 

@echo off
:: Based off of Server Launch Script by r4z0r49
:: Script Modified and fixed by Sykotix - http://dayz.sykotix.com
::
:: Usage: dayzsrv-log-rotater.bat servername
:: Example 1 - Will update using default profile: dayzsrv-log-rotater.bat 
:: Example 2 - Will update using profile for US6: dayzsrv-log-rotater.bat US6

:::::::::::::: CONFIG ::::::::::::::::::

:: Set your Arma2AO Base installation directory. LEAVE OFF THE ENDING \
set arma2srvpath=YOUR ROOT PATH

:: Set your Default server profile name. This is the name of the directory that stores your server.cfg
:: This will be used in the case that you don't launch this script without the server param.
:: Example: cfgdayz, US6, Chicago13, ect
:: DEFAULTPROFILE
set srvname=instance_11_Chernarus

:: Delete Original log files after they have been rotated? This keeps your logs more organized and saves space.
:: This will not work unless the server is stopped first. This option works best set to 1 when using FireDaemon's Pre/Post Service tab
set deloriglogs=1

::::::::::: ADVANCED CONFIG ::::::::::::
:: Don't touch anything below this point unless you know what your doing.

:: Setting Server Profile to Use
IF "%1"=="" (
set servername=%srvname%
) else (
set servername=%1
)

TITLE  DayZ %servername% Server Log Rotater

:: Set Debug Mode
set debug=0
:: Set Debug Timeout in seconds
set dbsecs=10

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::  STOP EDITING ::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: Display Debug output
if %debug% == 1 (
echo Server Name = %servername%
echo ArmaII Server Path = "%arma2srvpath%"
timeout %dbsecs%
)

:: Set Time and Date
SET HOUR=%time:~0,2%
SET dtStamp9=%date:~-4%%date:~4,2%%date:~7,2%_0%time:~1,1%%time:~3,2%_%time:~6,2%
SET dtStamp24=%date:~-4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%_%time:~6,2%
::Make Date Stamp
if "%HOUR:~0,1%" == " " (SET dtStamp=%dtStamp9%) else (SET dtStamp=%dtStamp24%)
ECHO Todays Date and time (%date%)(%time%) / %dtStamp%
if %debug% == 1 (
timeout %dbsecs%
)

echo (%date%) (%time%) Starting Log Rotation.

:: Make the Rotated Log Directorys
if exist "%arma2srvpath%\%servername%\RotatedLogs" goto maketsdir
mkdir "%arma2srvpath%\%servername%\RotatedLogs"
:maketsdir
if exist "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%" goto makebedir
mkdir "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%"
:makebedir
if exist "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\BattlEye" goto rotatelogs
mkdir "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\BattlEye"

:rotatelogs
:: Starting Log Rotation. If there are any other logs, just follow the format below, and make sure to NOT touch any of the varibles.
copy "%arma2srvpath%\%servername%\arma2oaserver.RPT" "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\arma2oaserver.RPT"
copy "%arma2srvpath%\%servername%\arma2oaserver.mdmp" "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\arma2oaserver.mdmp"
copy "%arma2srvpath%\%servername%\arma2oaserver.bidmp" "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\arma2oaserver.bidmp"
copy "%arma2srvpath%\%servername%\server_log.txt" "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\server_log.txt"
copy "%arma2srvpath%\%servername%\HiveExt.log" "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\HiveExt.log"
copy "%arma2srvpath%\%servername%\BattlEye\scripts.log" "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\BattlEye\scripts.log"
copy "%arma2srvpath%\%servername%\BattlEye\createvehicle.log" "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\BattlEye\createvehicle.log"
copy "%arma2srvpath%\%servername%\BattlEye\mpeventhandler.log" "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\BattlEye\mpeventhandler.log"
copy "%arma2srvpath%\%servername%\BattlEye\publicvariable.log" "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\BattlEye\publicvariable.log"
copy "%arma2srvpath%\%servername%\BattlEye\publicvariableval.log" "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\BattlEye\publicvariableval.log"
copy "%arma2srvpath%\%servername%\BattlEye\remoteexec.log" "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\BattlEye\remoteexec.log"
copy "%arma2srvpath%\%servername%\BattlEye\setdamage.log" "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\BattlEye\setdamage.log"
copy "%arma2srvpath%\%servername%\BattlEye\setpos.log" "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\BattlEye\setpos.log"
copy "%arma2srvpath%\%servername%\BattlEye\setvariable.log" "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\BattlEye\setvariable.log"
copy "%arma2srvpath%\%servername%\BattlEye\addmagazinecargo.log" "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\BattlEye\addmagazinecargo.log"

echo (%date%) (%time%) Logs are backed up now...
echo (%date%) (%time%) Removing original log files.
del /Q /F "%arma2srvpath%\%servername%\arma2oaserver.RPT"
del /Q /F "%arma2srvpath%\%servername%\arma2oaserver.mdmp"
del /Q /F "%arma2srvpath%\%servername%\arma2oaserver.bidmp"
del /Q /F "%arma2srvpath%\%servername%\server_console.log"
del /Q /F "%arma2srvpath%\%servername%\runtime.log"
del /Q /F "%arma2srvpath%\%servername%\BattlEye\scripts.log"
del /Q /F "%arma2srvpath%\%servername%\BattlEye\createvehicle.log"
del /Q /F "%arma2srvpath%\%servername%\BattlEye\mpeventhandler.log"
del /Q /F "%arma2srvpath%\%servername%\BattlEye\publicvariable.log"
del /Q /F "%arma2srvpath%\%servername%\BattlEye\publicvariableval.log"
del /Q /F "%arma2srvpath%\%servername%\BattlEye\remoteexec.log"
del /Q /F "%arma2srvpath%\%servername%\BattlEye\setdamage.log"
del /Q /F "%arma2srvpath%\%servername%\BattlEye\setpos.log"
del /Q /F "%arma2srvpath%\%servername%\BattlEye\setvariable.log"
del /Q /F "%arma2srvpath%\%servername%\BattlEye\addmagazinecargo.log"
del /Q /F "%arma2srvpath%\%servername%\HiveExt.log"

if %debug% == 1 (
timeout %dbsecs%
)

:: We're done here.
exit

In your BEC scheduler.xml, the last two jobs should be

 


    <job id="8">
        <day>1,2,3,4,5,6,7</day>
        <start>023000</start>
        <runtime>000000</runtime>
        <loop>0</loop>
        <cmd>#shutdown</cmd>
    </job>
	
	<job id='9'>
	<day>1,2,3,4,5,6,7</day>
	<start>023000</start>
	<runtime>000000</runtime>
	<loop>0</loop>
	<cmd>YOUR ROOT PATH\Server_Restart.bat</cmd>
</job>
</Scheduler>

 

There are other ways, incuding a monitor.bat file, which auto re opens if arma crashes, but I havent got around to doing that yet.

 

Link to comment
Share on other sites

  • 0
On 1/14/2017 at 3:11 PM, lwbuk said:

I do it like this.

You need BEC installed for the scheduler and then make 3  .bat files.

First called Server_Restart.bat

 


@echo off
echo.
echo KILL arma2oaserver.exe
set serverkill="YOUR SERVER ROOT PATH"
cd /d %serverkill%
taskkill /im arma2oaserver.exe
echo.
echo Kill Bec.exe
set beckill="YOUR BEC PATH"
cd /d %beckill%
taskkill /im bec.exe

timeout 5

echo.
echo Rotate Logs
start "start" "ROTATE LOGS .BAT PATH" 

timeout 5


echo.
echo Starting Dayz Server
:: start the server..
set dayzpath="YOUR ROOT PATH\"
cd /d %dayzpath%
start "start" "Server_Start_New.bat"
echo.
echo Starting Bec
timeout 20
:: start bec
set becpath="YOUR BEC PATH"
cd /d %becpath%
start "start" "bec.exe" -f Config.cfg
echo.
echo Server Started 100%

cls
@exit

 

second called Server_Start_New.bat


timeout 5

::Start Dayz Server::

start "arma2" /HIGH /affinity 2  "arma2oaserver.exe" -ip=xx.xx.xxx.xx -port=xxxx -maxmem=2047 -noPause "-config=instance_11_Chernarus\config.cfg" "-cfg=instance_11_Chernarus\basic.cfg" "-profiles=instance_11_Chernarus" -name=instance_11_Chernarus "-mod=@DayZ_Epoch;@DayZ_Epoch_Server;"

cls

@exit

 

Third called rotate_logs.bat, this isnt necesary if you dont want it though.

 


@echo off
:: Based off of Server Launch Script by r4z0r49
:: Script Modified and fixed by Sykotix - http://dayz.sykotix.com
::
:: Usage: dayzsrv-log-rotater.bat servername
:: Example 1 - Will update using default profile: dayzsrv-log-rotater.bat 
:: Example 2 - Will update using profile for US6: dayzsrv-log-rotater.bat US6

:::::::::::::: CONFIG ::::::::::::::::::

:: Set your Arma2AO Base installation directory. LEAVE OFF THE ENDING \
set arma2srvpath=YOUR ROOT PATH

:: Set your Default server profile name. This is the name of the directory that stores your server.cfg
:: This will be used in the case that you don't launch this script without the server param.
:: Example: cfgdayz, US6, Chicago13, ect
:: DEFAULTPROFILE
set srvname=instance_11_Chernarus

:: Delete Original log files after they have been rotated? This keeps your logs more organized and saves space.
:: This will not work unless the server is stopped first. This option works best set to 1 when using FireDaemon's Pre/Post Service tab
set deloriglogs=1

::::::::::: ADVANCED CONFIG ::::::::::::
:: Don't touch anything below this point unless you know what your doing.

:: Setting Server Profile to Use
IF "%1"=="" (
set servername=%srvname%
) else (
set servername=%1
)

TITLE  DayZ %servername% Server Log Rotater

:: Set Debug Mode
set debug=0
:: Set Debug Timeout in seconds
set dbsecs=10

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::  STOP EDITING ::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: Display Debug output
if %debug% == 1 (
echo Server Name = %servername%
echo ArmaII Server Path = "%arma2srvpath%"
timeout %dbsecs%
)

:: Set Time and Date
SET HOUR=%time:~0,2%
SET dtStamp9=%date:~-4%%date:~4,2%%date:~7,2%_0%time:~1,1%%time:~3,2%_%time:~6,2%
SET dtStamp24=%date:~-4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%_%time:~6,2%
::Make Date Stamp
if "%HOUR:~0,1%" == " " (SET dtStamp=%dtStamp9%) else (SET dtStamp=%dtStamp24%)
ECHO Todays Date and time (%date%)(%time%) / %dtStamp%
if %debug% == 1 (
timeout %dbsecs%
)

echo (%date%) (%time%) Starting Log Rotation.

:: Make the Rotated Log Directorys
if exist "%arma2srvpath%\%servername%\RotatedLogs" goto maketsdir
mkdir "%arma2srvpath%\%servername%\RotatedLogs"
:maketsdir
if exist "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%" goto makebedir
mkdir "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%"
:makebedir
if exist "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\BattlEye" goto rotatelogs
mkdir "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\BattlEye"

:rotatelogs
:: Starting Log Rotation. If there are any other logs, just follow the format below, and make sure to NOT touch any of the varibles.
copy "%arma2srvpath%\%servername%\arma2oaserver.RPT" "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\arma2oaserver.RPT"
copy "%arma2srvpath%\%servername%\arma2oaserver.mdmp" "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\arma2oaserver.mdmp"
copy "%arma2srvpath%\%servername%\arma2oaserver.bidmp" "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\arma2oaserver.bidmp"
copy "%arma2srvpath%\%servername%\server_log.txt" "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\server_log.txt"
copy "%arma2srvpath%\%servername%\HiveExt.log" "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\HiveExt.log"
copy "%arma2srvpath%\%servername%\BattlEye\scripts.log" "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\BattlEye\scripts.log"
copy "%arma2srvpath%\%servername%\BattlEye\createvehicle.log" "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\BattlEye\createvehicle.log"
copy "%arma2srvpath%\%servername%\BattlEye\mpeventhandler.log" "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\BattlEye\mpeventhandler.log"
copy "%arma2srvpath%\%servername%\BattlEye\publicvariable.log" "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\BattlEye\publicvariable.log"
copy "%arma2srvpath%\%servername%\BattlEye\publicvariableval.log" "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\BattlEye\publicvariableval.log"
copy "%arma2srvpath%\%servername%\BattlEye\remoteexec.log" "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\BattlEye\remoteexec.log"
copy "%arma2srvpath%\%servername%\BattlEye\setdamage.log" "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\BattlEye\setdamage.log"
copy "%arma2srvpath%\%servername%\BattlEye\setpos.log" "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\BattlEye\setpos.log"
copy "%arma2srvpath%\%servername%\BattlEye\setvariable.log" "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\BattlEye\setvariable.log"
copy "%arma2srvpath%\%servername%\BattlEye\addmagazinecargo.log" "%arma2srvpath%\%servername%\RotatedLogs\%dtStamp%\BattlEye\addmagazinecargo.log"

echo (%date%) (%time%) Logs are backed up now...
echo (%date%) (%time%) Removing original log files.
del /Q /F "%arma2srvpath%\%servername%\arma2oaserver.RPT"
del /Q /F "%arma2srvpath%\%servername%\arma2oaserver.mdmp"
del /Q /F "%arma2srvpath%\%servername%\arma2oaserver.bidmp"
del /Q /F "%arma2srvpath%\%servername%\server_console.log"
del /Q /F "%arma2srvpath%\%servername%\runtime.log"
del /Q /F "%arma2srvpath%\%servername%\BattlEye\scripts.log"
del /Q /F "%arma2srvpath%\%servername%\BattlEye\createvehicle.log"
del /Q /F "%arma2srvpath%\%servername%\BattlEye\mpeventhandler.log"
del /Q /F "%arma2srvpath%\%servername%\BattlEye\publicvariable.log"
del /Q /F "%arma2srvpath%\%servername%\BattlEye\publicvariableval.log"
del /Q /F "%arma2srvpath%\%servername%\BattlEye\remoteexec.log"
del /Q /F "%arma2srvpath%\%servername%\BattlEye\setdamage.log"
del /Q /F "%arma2srvpath%\%servername%\BattlEye\setpos.log"
del /Q /F "%arma2srvpath%\%servername%\BattlEye\setvariable.log"
del /Q /F "%arma2srvpath%\%servername%\BattlEye\addmagazinecargo.log"
del /Q /F "%arma2srvpath%\%servername%\HiveExt.log"

if %debug% == 1 (
timeout %dbsecs%
)

:: We're done here.
exit

In your BEC scheduler.xml, the last two jobs should be

 



    <job id="8">
        <day>1,2,3,4,5,6,7</day>
        <start>023000</start>
        <runtime>000000</runtime>
        <loop>0</loop>
        <cmd>#shutdown</cmd>
    </job>
	
	<job id='9'>
	<day>1,2,3,4,5,6,7</day>
	<start>023000</start>
	<runtime>000000</runtime>
	<loop>0</loop>
	<cmd>YOUR ROOT PATH\Server_Restart.bat</cmd>
</job>
</Scheduler>

 

There are other ways, incuding a monitor.bat file, which auto re opens if arma crashes, but I havent got around to doing that yet.

 

Thanks for the help.
I'm stuck somewhere though. When I go to run bec.exe i get an error in the command prompt that says it cannot locate the BEserver.cfg file. Now i looked around and I don't have that file in my battleye folder. Other people I see just made one and put some text in it.
RConPassword NotTellingYouLot
MaxPing 250
That's what I found. 
Any ideas why it wont load?

Thanks!

Link to comment
Share on other sites

  • 0

@LostKaus

here you have my files: http://www.mediafire.com/file/6afp6inam56tfq2/autorestart.rar

1-Drop battleye folder into serverRoot\instance_11_Chernarus\

2-The others 3 .bat files must be in your serverRoot-

3-now you need change the paths in the files:

A-open "monitor.bat" (located in your serverroot) and change the paths for your server route.
B-open "Premod_restart.bat" (located in your serverroot) and change the paths for your server route.
C-open "BEC_Control_Epoch.bat" (located in serverRoot\instance_11_Chernarus\BattlEye\Bec) and change the paths for your server route.
D-open "Config.cfg"(located in YourServerRoot\instance_11_Chernarus\BattlEye\Bec\Config\) and change the paths for your server route.

E-open "Shedule.xml" (located in YourServerRoot\instance_11_Chernarus\BattlEye\Bec\Config\)
and  needs add this at each last shedule id job:

<cmd>C:\Users\Administrador\Desktop\Dayz Epoch Server\Premod_restart.bat</cmd>  

 (change for ur server paths).

My example:

 <Scheduler>

<!-- 12:00 AM restart -->

<job id="0">
    <time>23:45:00</time>
    <delay>000000</delay>
    <day>1,2,3,4,5,6,7</day>
    <loop>0</loop>
    <cmd>say -1 This server will restart in 15 minutes</cmd>
    <cmdtype>0</cmdtype>
</job>

<job id="1">
    <time>23:55:00</time>
    <delay>000000</delay>
    <day>1,2,3,4,5,6,7</day>
    <loop>0</loop>
    <cmd>say -1 This server will restart in 5 minutes</cmd>
    <cmdtype>0</cmdtype>
</job>

<job id="2">
    <time>23:59:00</time>
    <delay>000000</delay>
    <day>1,2,3,4,5,6,7</day>
    <loop>0</loop>
    <cmd>say -1 This server will restart in 1 minute, Log out now!</cmd>
    <cmdtype>0</cmdtype>
</job>

<job id="3">
    <time>00:00:00</time>
    <delay>000000</delay>
    <day>1,2,3,4,5,6,7</day>
    <loop>0</loop>
    <cmd>#shutdown</cmd>
    <cmdtype>0</cmdtype>
</job>

<job id="4">
    <time>00:00:10</time>
    <delay>000000</delay>
    <day>1,2,3,4,5,6,7</day>
    <loop>0</loop>
    <cmd>C:\Users\Administrador\Desktop\Dayz Epoch Server\Premod_restart.bat</cmd>
    <cmdtype>1</cmdtype>
</job>

<!-- End 12:00 AM restart -->

 

for now on,, start your server clicking on "monitor.bat".. the restart will be each 3hours. example 00:00hs , 03:00am, 06am, 09am, 12pm, 15pm, 18pm, 21pm, 00,00am.  To test it.. change the hour of your pc.. for example put 23:55am.  start your server with monitor.bat and when your pc clock shows 00:00hs server must be made the restart.

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
  • Advertisement
  • Discord

×
×
  • Create New...