Restart script

5 posts in this topic

Hi Guys,

Hoping you can help me with my restart script. It works fine apart from one problem, it does not kill the previous instance of arma. So after 12 hours I have 4 instances of arma running at the same time and my fps on the server is suffering badly as a result. How do I/what code do I need to add to make my restart script kill arma forcefully at restart before starting it up again?

My restart script is below.

@echo off

set gameserver=Arma Exile

title %The Fluffy Basement% Auto Restart / Process Checker


REM How long until auto restart?
set hours="3"
set minutes="0"
set seconds="0"

REM // Launch parameters
start "Exile" /high "arma3server.exe" -mod=@Arma_Enhanced_Movement;@AdvancedTowing;@AdvancedSlingLoading;@ASDG_JR;@JSRS4APEX;@RHSAFRF;@RHSGREF;@RHSUSAF;@NATO_Rus_Vehicle;@NATO_Rus_Weapons;@exile; -servermod=@exileserver; -config=C:\Arma\Server\@ExileServer\config.cfg -port=2302 -profiles=SC -cfg=C:\Arma\Server\@ExileServer\basic.cfg -name=SC -autoinit -enableHT

REM //////// You do not need to update anything else below this line ////////

REM Pull, display and create some time functions
for /f "delims=" %%G IN ('powershell "(get-date %time%).AddHours(%hours%).AddMinutes(%minutes%).AddSeconds(%seconds%).ToString('yyyyMMddHHmmss')"') do set endtime=%%G
for /f "delims=" %%G IN ('powershell "(get-date %time%).ToString('HH:mm:ss')"') do set nowtimeclean=%%G
for /f "delims=" %%G IN ('powershell "(get-date %time%).AddHours(%hours%).AddMinutes(%minutes%).AddSeconds(%seconds%).ToString('HH:mm:ss')"') do set endtimeclean=%%G

echo %time% - %gameserver% Server started at %nowtimeclean% and will restart at %endtimeclean%


for /f "delims=" %%G IN ('powershell "(get-date %time%).ToString('yyyyMMddHHmmss')"') do set nowtime=%%G

REM ////////// TIMER CHECK ///////////
if "%nowtime%" gtr "%endtime%" (
echo %time% - It is time to restart %gameserver%!
goto restartarma
REM ////////// END TIMER CHECK ///////////

REM ////////// PROCESS CHECK ///////////
tasklist /FI "IMAGENAME eq arma3server.exe" 2>NUL | find /I /N "arma3server.exe">NUL
if "%ERRORLEVEL%"=="1" (
echo %time% - The process is not running, restart %gameserver%!
goto restartarma
REM ////////// END PROCESS CHECK ///////////

REM restart not needed. Check again in 3 seconds.
goto checkarma

REM Either the server crashed or it is time for a restart. Kill the process and go to start.
START taskkill /f /im arma3server.exe 2>nul
goto start

Share this post

Link to post
Share on other sites

This is what I have for when it is supposed to kill the task and restart the server

echo The server is restarting...
timeout 1 >nul
taskkill /F /IM arma3server.exe >nul
timeout 5 >nul
goto start

Not entirely familiar with batch files but from what I can see you could probably remove that 2 from the 2>nul part and you can also remove the /t and /nobreak from timeout as to be honest they aren't really needed

Share this post

Link to post
Share on other sites
13 hours ago, Johnny82 said:

@Surge132 thanks for the input. I will give it a go. Do you ever have issues with the tasking comman's not actually killing the server like what Im explaining? 

I haven't had any experience with that thus far. To me that just sounds like an issue with your batch file not getting to the task where it says to kill it. I usually like to try and place and echo saying that it's gotten to a part to debug or trying to use the batch version of the if/else statements.

Share this post

Link to post
Share on other sites

I changed the taskill to caps, /F /I'M and removed the 5 timrout and hasn't happened since so your advice seems to have worked! Thanks pal


Edited by Johnny82

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.