//Is the server down for anyone?

So I figured, if I'm going to complain about something, I should probably at least give a suggestion for a solution to you guys.

@echo off

:: Put into directory YOUR_ARKSERVER_DIRECTORY\ShooterGame\Binaries\Win64
:: You also need to have SteamCMD installed

:: Set config paths here
set ark_server_path=d:\Alex_Dev\ark_server\
set steamcmd_path=d:\Alex_Dev\ark_server\SteamCMD\
set savedark_backup_path=d:\Alex_Dev\ark_server_BU\
:: Steam query port
set ark_server_qport=27015
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

timeout /T 5 /nobreak

:: Check if process is running
tasklist /FI "IMAGENAME eq ShooterGameServer.exe" 2>NUL | find /I /N "ShooterGameServer.exe">NUL
if "%ERRORLEVEL%"=="0" goto :PULSE
::update and start
goto :UPDATE

:START

::Restart times for the Server.
set A=0:00
set B=6:00
set C=12:00
set d=18:00

:: Check if process is still running
tasklist /FI "IMAGENAME eq ShooterGameServer.exe" 2>NUL | find /I /N "ShooterGameServer.exe">NUL
if "%ERRORLEVEL%"=="0" goto :PULSE
::start if dead
goto :STARTSERVER

exit


:PULSE
cls

::checks if it's restart time
set NOW=%time:~0,5%
if "%A%"=="%NOW%" goto :GO
if "%B%"=="%NOW%" goto :GO
if "%C%"=="%NOW%" goto :GO
if "%D%"=="%NOW%" goto :GO
echo Time checked at %time%
timeout /T 5 /nobreak > NUL
goto :START


:GO
echo It is %NOW%>>restartlog.txt
echo %time%: Beginning %NOW% restart>>restartlog.txt
goto :RESTART


:RESTART
::kill the process
echo %time%: Killing process>>restartlog.txt
echo Killing process...
TASKKILL /F /IM "ShooterGameServer.exe"
timeout /T 20 /nobreak


::check if killed
echo %time%: Checking process>>restartlog.txt
echo %time%: Checking process
tasklist /FI "IMAGENAME eq ShooterGameServer.exe" 2>NUL | find /I /N "ShooterGameServer.exe">NUL
if "%ERRORLEVEL%"=="0" (
::try again if not dead
echo %time%: Trying to kill process again>>restartlog.txt
echo Trying to kill process again
goto :RESTART
)
goto :UPDATE


:STARTSERVER
start %ark_server_path%ShooterGame\Binaries\Win64\ShooterGameServer.exe "../../../ShooterGame/ShooterGame.uproject" 

"/Game/Maps/TheIslandSubMaps/TheIsland?QueryPort=%ark_server_qport%?listen" -nosteamclient -game -server -log
::check if started after 20 seconds
timeout /T 20 /nobreak
tasklist /FI "IMAGENAME eq ShooterGameServer.exe" 2>NUL | find /I /N "ShooterGameServer.exe">NUL
::if process is running
if "%ERRORLEVEL%"=="0" goto :STARTED
::if process is not running
echo %time%: Process not found. Trying to start again.>>restartlog.txt
goto :STARTSERVER

:STARTED
echo %time%: Server was started>>restartlog.txt
goto :START


:UPDATE
cls
echo Backing up ARK
echo %time%: Backing up ARK>>restartlog.txt
::DO NOT CHANGE - START
set query_port=%ark_server_qport%
set savedark_path=%ark_server_path%ShooterGame\Saved\SavedArks
xcopy /f /s /v /z /i /-y /y %savedark_path% %savedark_backup_path%\%DATE:~-4%-%DATE:~4,2%-%DATE:~7,2%
echo Starting game update
echo %time%: Starting game update>>restartlog.txt
cd %steamcmd_path%
steamcmd.exe +login anonymous +force_install_dir %ark_server_path% +app_update 376030 +quit
::DO NOT CHANGE - END
goto :STARTSERVER

exit

Beware, this script DOES NOT force the server to save before killing it. It IS possible to implement this, but I'm not sure if you can do it on a shared host. it involves installing Arcon, which gives you command line access to the command line in game. Then before a reboot, you would just execute the following rcon commands from the script: enablecheats YOURPASSWORD setcheatplayer true admincheat saveworld

/r/jurassickingdoms Thread Parent