# How to make a server auto restart

#### Sonicscream

##### New Member
In batch, do something like this:

@echo off
title DayZ Server Watcher
color 0a
:top
echo Server has been started!
start /wait PATHTOSERVEREXEWITHCOMMANDLINE
cls
echo Server has exited, restarting!
goto top

#### Sonicscream

##### New Member
Code:
@echo off
color 0a
title Server Starter
:top
echo Executing pMain()
.\MySQL\bin\mysql --user=root --password=root --host=127.0.0.1 --port=3316 --database=hivemind --execute="call pMain()"
ping 127.0.0.1 -n 5 >NUL
echo Complete!
ping 127.0.0.1 -n 1 >NUL
cls

echo Launching And Watching Server
start /wait .\Expansion\beta\arma2oaserver.exe -mod=@dayz;@hive -name=cfgdayz -config=cfgdayz\server.cfg -cfg=cfgdayz\arma2.cfg -profiles=cfgdayz -world=Chernarus -exThreads=0 -maxMem=1024
ping 127.0.0.1 -n 5 >NUL
echo Server has exited ... Restarting!
ping 127.0.0.1 -n 1 >NUL
cls
goto top
Paste all of that into a batch file (filename.bat) using notepad and save the batch file in your server root (should be in same directory as @START_SERVER.bat).

After you've done that, just double click the batch file and it will start your server and restart it if it crashes. If you want to shut your server down with out it restarting, exit the batch file.

#### Quarterbreed

##### Well-Known Member
Code:
@echo off
color 0a
title Server Starter
:top
echo Executing pMain()
.\MySQL\bin\mysql --user=root --password=root --host=127.0.0.1 --port=3316 --database=hivemind --execute="call pMain()"
ping 127.0.0.1 -n 5 >NUL
echo Complete!
ping 127.0.0.1 -n 1 >NUL
cls

echo Launching And Watching Server
start /wait .\Expansion\beta\arma2oaserver.exe -mod=@dayz;@hive -name=cfgdayz -config=cfgdayz\server.cfg -cfg=cfgdayz\arma2.cfg -profiles=cfgdayz -world=Chernarus -exThreads=0 -maxMem=1024
ping 127.0.0.1 -n 5 >NUL
echo Server has exited ... Restarting!
ping 127.0.0.1 -n 1 >NUL
cls
goto top
Paste all of that into a batch file (filename.bat) using notepad and save the batch file in your server root (should be in same directory as @START_SERVER.bat).

After you've done that, just double click the batch file and it will start your server and restart it if it crashes. If you want to shut your server down with out it restarting, exit the batch file.
Totally my bad.. i ment auto restart every so many hours

#### beowolfschaefer

Staff member
You can use the BEC (Battleye Extended Controls) scheduler system. You can find more information about it here.

This is the one I use, it is set up to reboot the server every five hours. Rather than being set for specific times of the day it is just a countdown timer from when the server start. This way if you restart for one reason or another or the server crashes you don't wind up with a short play session. It also gives hourly updates on uptime and 10, 5, 3, 2 and 1 minute warnings before the reboot.

Code:
<?xml version="1.0"?>
<Scheduler>

<job id="0">
<time>010000</time>
<day>1,2,3,4,5,6,7</day>
<loop>0</loop>
<cmd>say -1 Server uptime is one hour. In four hours this server will perform an automated reboot.</cmd>
<cmdtype>0</cmdtype>
</job>

<job id="1">
<time>020000</time>
<day>1,2,3,4,5,6,7</day>
<loop>0</loop>
<cmd>say -1 Server uptime is two hours. In three hours this server will perform an automated reboot.</cmd>
<cmdtype>0</cmdtype>
</job>

<job id="2">
<time>030000</time>
<day>1,2,3,4,5,6,7</day>
<loop>0</loop>
<cmd>say -1 Server uptime is three hours. In two hours this server will perform an automated reboot.</cmd>
<cmdtype>0</cmdtype>
</job>

<job id="3">
<time>040000</time>
<day>1,2,3,4,5,6,7</day>
<loop>0</loop>
<cmd>say -1 Server uptime is four hours. In one hour this server will perform an automated reboot.</cmd>
<cmdtype>0</cmdtype>
</job>

<job id="4">
<time>045000</time>
<day>1,2,3,4,5,6,7</day>
<loop>0</loop>
<cmd>say -1 In 10 minutes this server will perform an automated reboot.</cmd>
<cmdtype>0</cmdtype>
</job>

<job id="5">
<time>045500</time>
<day>1,2,3,4,5,6,7</day>
<loop>0</loop>
<cmd>say -1 In 5  minutes this server will perform an automated reboot.</cmd>
<cmdtype>0</cmdtype>
</job>

<job id="6">
<time>045700</time>
<day>1,2,3,4,5,6,7</day>
<loop>0</loop>
<cmd>say -1 In 3 minutes this server will perform an automated reboot.</cmd>
<cmdtype>0</cmdtype>
</job>

<job id="7">
<time>045800</time>
<day>1,2,3,4,5,6,7</day>
<loop>0</loop>
<cmd>say -1 In 2 minutes this server will perform an automated reboot.</cmd>
<cmdtype>0</cmdtype>
</job>

<job id="8">
<time>045900</time>
<day>1,2,3,4,5,6,7</day>
<loop>0</loop>
<cmd>say -1 In 1 minute this server will perform an automated reboot.</cmd>
<cmdtype>0</cmdtype>
</job>

<job id="9">
<time>050000</time>
<day>1,2,3,4,5,6,7</day>
<loop>0</loop>
<cmd>#shutdown</cmd>
<cmdtype>0</cmdtype>
</job>

<job id="10">
<time>050000</time>
<day>1,2,3,4,5,6,7</day>
<loop>0</loop>
<cmd>c:\start-namalsk-server.bat</cmd>
<cmdtype>1</cmdtype>
</job>

</Scheduler>

Just set up BEC and adjust the last line to point to your server startup batch file.

#### Quarterbreed

##### Well-Known Member
I looked at it but not sure where to install it on my server and how my make it launch when i start my server..

#### beowolfschaefer

Staff member
I looked at it but not sure where to install it on my server and how my make it launch when i start my server..
You can install it anywhere you want. I just put it in my Arma2OA directory and then I have it launched by the same batch that starts the server.

Here's my server startup batch, you can see in the second line I call the BEC startup
Code:
perl db_spawn_vehicles.pl --password 123456 --name dayzpanthera --instance 1
start dayzbec.bat
"Expansion\beta\arma2oaserver.exe" -port=2314 "-config=dayz_1.panthera2\config_8fb97276.cfg" "-cfg=dayz_1.panthera2\basic.cfg" "-profiles=dayz_1.panthera2" -name=Bliss "-mod=@dayzpanthera;@bliss_1.panthera2" -noPause -noSound -cpuCount=4 -exThreads=1 -maxMem=2047
And my BEC startup batch (I have a delay built in so that the server has time to start and BEC does not timeout when looking for it).
Code:
timeout /t 60
cd "C:\DayZ\panthera\BEC\"
"C:\DayZ\panthera\BEC\Bec.exe" -f config.cfg
exit

#### Quarterbreed

##### Well-Known Member
Do i put this in my dayz server start file

#### beowolfschaefer

Staff member
The first code section in my last post IS a dayz startup. You'd have to adjust it for your use of course.

#### Quarterbreed

##### Well-Known Member
when i run the bat for bec it says the config file has not a vaild file format

#### beowolfschaefer

Staff member
Did you make a config file? You can find information on it here. BEC comes with an example config file you can rename.

#### Quarterbreed

##### Well-Known Member
this is my C:\ServerTools\Bec\Config
Ip = 127.0.0.1
Port = 2302
BePath = C:\ArmA 2 Server\BattlEye
LogDir = Server1
Commands = Commands.xml
Scheduler = scheduler.xml

this is my dayzbec bat file located in my ARma 2 server folder

timeout /t 60
cd "C:\ServerTools\BEC\"
"C:\ServerTools\BEC\Bec.exe" -f config.cfg
exit

#### beowolfschaefer

Staff member
Oh I think the example config file has "#[BEC]" by default. You wanna remove "#" from the [] lines I think. Saw this thread on it here.

#### Quarterbreed

##### Well-Known Member
Oh I think the example config file has "#[BEC]" by default. You wanna remove "#" from the [] lines I think. Saw this thread on it here.
i just posted my config file above your post im not sure what you mean

#### beowolfschaefer

Staff member
You are missing the "[BEC]". It should be like this

Code:
[BEC]
Ip = 127.0.0.1
Port = 2302
BePath = C:\ArmA 2 Server\BattlEye
LogDir = Server1
Commands = Commands.xml
Scheduler = scheduler.xml
You'll want to uncomment the [Misc] section as well I think.

#### Quarterbreed

##### Well-Known Member
I dont have the [BEC] in the config, should i have it..

Oh do i have to add a command for the dayzbec.bat file in the server start.bat

#### beowolfschaefer

Staff member
I dont have the [BEC] in the config, should i have it..
Yes. This is the example config file...
Code:
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Example Config file for Bec.
# Everything is disabled by default
# Enable/disable a parameter by Comment/Uncomment it with a #
# You can also delete all parameters that are not in use.
# If you are unsure how to configure this file read the online docs.
# http://ibattle.org/install-and-configure/

#####################################################
#[Bec]
#Ip = 127.0.0.1
#Port = 2302
#BePath = C:\SERVER1\BattlEye
#LogDir = MyServer1
#Commands = Commands.xml

#####################################################
## Optional settings for misc functions
#[Misc]
#AsciiNickOnly = True
#AsciiChatOnly = True
#IgnoreChatChars = Â£Ã¦Ã¸Ã¥
#ServerExeName = A2Server_1.exe
#Warnings = 3
#Color = 0c
#Timeout = 40
#KickLobbyIdlers = 300
#Scheduler = Scheduler.xml
#MaxPlayerNameLength = 18
#DisallowPlayerNameChars = [](){}<>/\^Â¨|Â§!"'#Â¤%&@Â£$â‚¬ #ChatChannelFiles = true ################### #FloodControl1 = 5 # Or #FloodControl2 = 5 #FloodSampleTime = 5 #FloodLockTime = 10 ################### ##################################################### ## Optional settings related to Chat restriction #[ChatRestriction] #Global = 3 #Side = -1 #Group = -1 #Vehicle = -1 #Command = -1 #Commander = -1 #Direct = -1 ##################################################### ## Optional settings related to Reporting function #[Reporter] #User = Donald Duck #Password = 313 ##################################################### # Optional settings related to Heartbeat #[Heartbeat] #BanFile0 = C:\SERVER2\BattlEye\bans.txt #BanFile1 = C:\SERVER3\BattlEye\bans.txt You will want to uncomment some of the lines like this Code: # Example Config file for Bec. # Everything is disabled by default # Enable/disable a parameter by Comment/Uncomment it with a # # You can also delete all parameters that are not in use. # If you are unsure how to configure this file read the online docs. # http://ibattle.org/install-and-configure/ ##################################################### [Bec] Ip = 127.0.0.1 Port = 2302 BePath = C:\SERVER1\BattlEye LogDir = MyServer1 Admins = Admins.xml Commands = Commands.xml ##################################################### ## Optional settings for misc functions [Misc] AsciiNickOnly = True AsciiChatOnly = True IgnoreChatChars = Â£Ã¦Ã¸Ã¥ ServerExeName = A2Server_1.exe NickFilterFile = BadNames.txt WordFilterFile = BadWords.txt Warnings = 3 Color = 0c Timeout = 40 KickLobbyIdlers = 300 Scheduler = Scheduler.xml MaxPlayerNameLength = 18 DisallowPlayerNameChars = [](){}<>/\^Â¨|Â§!"'#Â¤%&@Â£$â‚¬
ChatChannelFiles = true
###################
#FloodControl1 = 5
# Or
#FloodControl2 = 5
#FloodSampleTime = 5
#FloodLockTime = 10
###################

#####################################################
## Optional settings related to Chat restriction
#[ChatRestriction]
#Global = 3
#Side = -1
#Group = -1
#Vehicle = -1
#Command = -1
#Commander = -1
#Direct = -1

#####################################################
## Optional settings related to Reporting function
#[Reporter]
#User = Donald Duck

#####################################################
# Optional settings related to Heartbeat
#[Heartbeat]
#BanFile0 = C:\SERVER2\BattlEye\bans.txt
#BanFile1 = C:\SERVER3\BattlEye\bans.txt

Oh do i have to add a command for the dayzbec.bat file in the server start.bat
Yes

#### Quarterbreed

##### Well-Known Member
ok now when i try to start the dayzbec file, now bec says it cant find the beserver file :/.. oh and how would i add it to my start server.bat