[Release] Auto Restart Server

with my server it goes c:\server\server-data\ to get to resources etc and just c:\server for all the base files

but I keep getting “cannot find specified path”

@echo off
RMDIR /s /q "C:\RGN\server-data\cache\files"
echo ----------------------------------
echo -
echo To restart the server, Press CTRL + C then "runserver"
echo -
echo ----------------------------------
echo -
echo Press any key to launch the server.
echo -
pause > nul
CLS

:: CONFIGURATION

TITLE GTA 5 FIVEM SERVER
set reboot=6
set reboot2=12
set reboot3=18
set reboot4=0
set reboot_done=0
set reboot_done2=0
set reboot_done3=0
set reboot_done4=0
set location=C:\RGN\

:: CONFIGURATION

:start

set dat=%date:~6,4%-%date:~3,2%-%date:~0,2%
set backup=%location%logs\%dat%.txt

:: Partie sauvegarde

echo [%time%] - Open server
echo [%time%] - Open server >> %backup%
echo [%time%] - Launching the backup 
echo [%time%] - Launching the backup >> %backup%
xcopy %location%\server-data\"resources" %location%\backups\"%dat%" /E /H /R /Y /I /D  >> %backup%
echo [%time%] - Backup ends
echo [%time%] - Backup ends >> %backup%

:: Partie sauvegarde

:: Partie lancement

start %location%run.cmd +exec server.cfg %*

:: Partie lancement

goto loop

:loop
timeout /t 30>null
set tps=%TIME:~-0,2%
    if %tps% == %reboot% (
        if %reboot_done% == 0 (
            echo [%time%] - We close the server for reboot && echo [%time%] - We close the server for reboot >> %backup%
            taskkill /IM cmd.exe /FI "WINDOWTITLE ne GTA 5 FIVEM SERVER*" >> %backup%
			echo ----------------------------------------------------------------------
            set reboot_done=1
            goto start
        ) else (
            goto loop
        )
    ) else (
        set reboot_done=0
        goto loop
    )
	
	
:: Partie lancement 2

goto loop

:loop

timeout /t 30>null
set tps2=%TIME:~-0,2%
    if %tps2% == %reboot2% (
        if %reboot_done2% == 0 (
            echo [%time%] - We close the server for reboot && echo [%time%] - We close the server for reboot >> %backup%
            taskkill /IM cmd.exe /FI "WINDOWTITLE ne GTA 5 FIVEM SERVER*" >> %backup%
			echo ----------------------------------------------------------------------
            set reboot_done2=1
            goto start
        ) else (
            goto loop
        )
    ) else (
        set reboot_done2=0
        goto loop
    )
	

:: Partie lancement 3

goto loop

:loop

timeout /t 30>null
set tps3=%TIME:~-0,2%
    if %tps3% == %reboot3% (
        if %reboot_done3% == 0 (
            echo [%time%] - We close the server for reboot && echo [%time%] - We close the server for reboot >> %backup%
            taskkill /IM cmd.exe /FI "WINDOWTITLE ne GTA 5 FIVEM SERVER*" >> %backup%
			echo ----------------------------------------------------------------------
            set reboot_done3=1
            goto start
        ) else (
            goto loop
        )
    ) else (
        set reboot_done3=0
        goto loop
    )

:: Partie lancement 4

goto loop

:loop

timeout /t 30>null
set tps4=%TIME:~-0,2%
    if %tps4% == %reboot4% (
        if %reboot_done4% == 0 (
            echo [%time%] - We close the server for reboot && echo [%time%] - We close the server for reboot >> %backup%
            taskkill /IM cmd.exe /FI "WINDOWTITLE ne GTA 5 FIVEM SERVER*" >> %backup%
			echo ----------------------------------------------------------------------
            set reboot_done4=1
            goto start
        ) else (
            goto loop
        )
    ) else (
        set reboot_done4=0
        goto loop
    )	

I also advise you to do a reboot with “The Task Planner”.

The Start (You can change the “set title=”, if you change it don’t forget to change it in the stop.bat too)

For the start do not put the same time as the stop for example the stop is at 20:00:00 then put the start at 20:00:10

Start_Server.cmd (666 Bytes)

Stop.bat (67 Bytes)

Stage 1

Stage 2
qBSWwserBf

Stage 3
Mpxweg2NSV

Stage 4

Stage 5
vDo4bessF8

Stage 6
UxtEa0pNMV

If you want to add more reboot time

And

5EnBLcf9js

1 Like

Hi , Taskkill part doesn’t works for me , someone got an idea ?

@echo off
RMDIR /s /q "D:\FXServer\cache\files"
echo ----------------------------------
echo -
echo Pour relancer votre serveur, faites CTRL + C puis "runserver"
echo -
echo ----------------------------------
echo -
echo Appuyez sur une TOUCHE pour lancer votre serveur
echo -
pause > nul
CLS

:: CONFIGURATION

TITLE GTA 5 FIVEM SERVER
set reboot=6
set reboot2=12
set reboot3=14
set reboot4=0
set reboot_done=0
set reboot_done2=0
set reboot_done3=30
set reboot_done4=0
set location=D:\FXServer\

:: CONFIGURATION

:start

set dat=%date:~6,4%-%date:~3,2%-%date:~0,2%
set backup=%location%logs\%dat%.txt

:: Partie sauvegarde

echo [%time%] - Serveur ouvert
echo [%time%] - Serveur ouvert >> %backup%
echo [%time%] - Lancement de la sauvegarde 
echo [%time%] - Lancement de la sauvegarde >> %backup%
xcopy %location%\"resources" %location%\backups\"%dat%" /E /H /R /Y /I /D  >> %backup%
echo [%time%] - Sauvegarde termine
echo [%time%] - Sauvegarde termine >> %backup%

:: Partie sauvegarde

:: Partie lancement

start %location%run.cmd +exec server.cfg +exec permissions.cfg%*

:: Partie lancement

goto loop

:loop
timeout /t 30>null
set tps=%TIME:~-0,2%
    if %tps% == %reboot% (
        if %reboot_done% == 0 (
            echo [%time%] - On ferme le serveur pour reboot && echo [%time%] - On ferme le serveur pour reboot >> %backup%
            taskkill /im D:\FXServer\cmd.exe /f "WINDOWTITLE ne GTA 5 FIVEM SERVER*" >> %backup%
			echo ----------------------------------------------------------------------
            set reboot_done=1
            goto start
        ) else (
            goto loop
        )
    ) else (
        set reboot_done=0
        goto loop
    )
	
	
:: Partie lancement 2

goto loop

:loop

timeout /t 30>null
set tps2=%TIME:~-0,2%
    if %tps2% == %reboot2% (
        if %reboot_done2% == 0 (
            echo [%time%] - On ferme le serveur pour reboot && echo [%time%] - On ferme le serveur pour reboot >> %backup%
            taskkill /im D:\FXServer\cmd.exe /f "WINDOWTITLE ne GTA 5 FIVEM SERVER*" >> %backup%
			echo ----------------------------------------------------------------------
            set reboot_done2=1
            goto start
        ) else (
            goto loop
        )
    ) else (
        set reboot_done2=0
        goto loop
    )
	

:: Partie lancement 3

goto loop

:loop

timeout /t 30>null
set tps3=%TIME:~-0,2%
    if %tps3% == %reboot3% (
        if %reboot_done3% == 0 (
            echo [%time%] - On ferme le serveur pour reboot && echo [%time%] - On ferme le serveur pour reboot >> %backup%
            taskkill /im D:\FXServer\cmd.exe /f "WINDOWTITLE ne GTA 5 FIVEM SERVER*" >> %backup%
			echo ----------------------------------------------------------------------
            set reboot_done3=1
            goto start
        ) else (
            goto loop
        )
    ) else (
        set reboot_done3=0
        goto loop
    )

:: Partie lancement 4

goto loop

:loop

timeout /t 30>null
set tps4=%TIME:~-0,2%
    if %tps4% == %reboot4% (
        if %reboot_done4% == 0 (
            echo [%time%] - On ferme le serveur pour reboot && echo [%time%] - On ferme le serveur pour reboot >> %backup%
            taskkill /im D:\FXServer\cmd.exe /f "WINDOWTITLE ne GTA 5 FIVEM SERVER*" >> %backup%
			echo ----------------------------------------------------------------------
            set reboot_done4=1
            goto start
        ) else (
            goto loop
        )
    ) else (
        set reboot_done4=0
        goto loop
    )

Yes, it’s quite normal because you changed a line that I never said to change.

I did tests today to see if it still works with the new version of the fxserver, and everything works

I just delete the backup part so I do not have to worry about it. Is it possible to add a function for the process to be high???

can anyone help me set this up properly whateever I do it doesnt work

1 Like

@slizzarn1 @Charuwat_Phadungwian @halukaliev #learntocode

I have no problem except 1 when my reboot server is not found in five M? if a person knows how to do thank you

hello how can I make it work through zap-hosting?

1 Like

You can’t install it on ZAP’s GSP offerings because:

  1. They use linux
  2. You have no access to the OS to run a .bat file

Hello look my error plz im use Task Planner for Restart auto my server.
image

You’re executing the config from the wrong directory. Please read the documentation again.

it run as admin so it gives me this error that i am missing the master key but if run normal its fine it works if i do it manualy but the program cant get it started since it starts it with admin privaleges and i cant find where i can turn that off

nvm i found a solution Start_Server.cmd (673 Bytes) just copy the top part if u get same issues and change it to right location ofcourse

Aconteceu a mesma coisa comigo aff

not going to lie dude if you dont have backs up of your server then you had it coming,

i really dont think this once script can remove your whole server dude

Removeu mas eu tinha backup o problema que ele fica abrindo varias estancias

Toda hora abre uma nova e não fecha a anterior

thats unfortunate

why don’t you close the cmd after it starts, there are several cmds open, ask for terrible english

task kill not working