How to make a server auto restart

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
 
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.
 
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
 
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.
 
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
 
this is my C:\ServerTools\Bec\Config
Ip = 127.0.0.1
Port = 2302
BePath = C:\ArmA 2 Server\BattlEye
LogDir = Server1
Admins = Admins.xml
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
 
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
Admins = Admins.xml
Commands = Commands.xml
Scheduler = scheduler.xml

You'll want to uncomment the [Misc] section as well I think.
 
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
 
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
#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
#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
#Password = 313
 
 
#####################################################
# 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
 
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
 
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

sounds like you have your BE path wrong. As for adding it to your server.bat just add "start dayzbec.bat" before the executable.
 
Back
Top