[Release] Server Auto Restart

maybe increase the pause time?

Is there any way to say in a chat message for example “Server restarting in less than 5 minutes you should log out” or in the console ?

Thanks

2 Likes

Any server restart that works for the latest version of FiveM? I have no idea how to do auto server restarts on ubuntu 16

how you do a server restart on fxserver linux?

1 Like

bump, any way to do this on fx?

Insert this into run.bat

:loop
timeout /t 1
@RD /S /Q “C:\FXServer\ServerData\cache”
start C:\FXServer\run.cmd +exec server.cfg
timeout /t 14400 >null
taskkill /f /im FXServer.exe >null
goto loop

then go out drinking with friends celebrating your new freedom

3 Likes

im on linux :frowning:
How ever i did make my own restart script from scratch after 3 hours of research :frowning:
Thanks!

1 Like

CruelAlpha, care to share? I’ve been trying to figure out a script to restart my fxserver and with my very very basic knowledge of linux, I have yet to be able to create one.

https://www.digitalocean.com/community/tutorials/how-to-use-a-simple-bash-script-to-restart-server-programs

After i start my server i have to manually restart sessionmanager, is there a way of doing that in auto restarts?

Ok, so this should be as complete as it needs to be.
2 Hour Restart, Cache Flush, Session Manager FIX, Console Spam FIX & Countdown timers.
For this to function you’ll need to edit server.cfg in the root of the FiveM Server Folder in this case, C:\FXServer add this line near the bottom of the file " restart sessionmanager " NOTE !NO QUOTATIONS! Save the file & completed.

Now copy this directly into your Server_Start.cmd paste & save file

:loop
@echo Clearing Server Cache Files
timeout /t 3
cd %FXServer%
rd /s /q cache
timeout /t 1 >nul
@echo off
cls
@echo Hit Enter In This Window To Restart Server Immediately, Keep This Window Open For Automatic 2 Hour Server Restarts.
start “FMServer” C:\FXServer\run.cmd +exec server.cfg
timeout /t 7200
taskkill /f /im FXServer.exe
@echo Server Shutdown Successfully.
timeout /t 2 >nul
taskkill /f /fi “WindowTitle eq FMServer”
@echo Server Is Restarting Now.
timeout /t 10
goto loop

1 Like

Why are you flushing cache folder every time the server autorestarts? There is literally no need.

Anyone have an idea on how to do this with multiple servers? What would i need to rename and change to do this? I have 3 servers and it kills the wrong ones sometimes just gets very confusing.

start “FMServer1” C:\FXServer\run.cmd +exec server.cfg
start “FMServer2” C:\FXServer\run.cmd +exec server.cfg
start “FMServer3” C:\FXServer\run.cmd +exec server.cfg
Should be able to naming them individually
And to kill tasks
taskkill /f /fi “WindowTitle eq FMServer1”
taskkill /f /fi “WindowTitle eq FMServer2”
taskkill /f /fi “WindowTitle eq FMServer3”

I see thank you man appreciate it.

:loop
@echo Clearing Server Cache Files
timeout /t 3
cd %FXServer%
timeout /t 1 >nul
@echo off
cls
@echo Hit Enter In This Window To Restart Server Immediately, Keep This Window Open For Automatic 2 Hour Server Restarts.
start “server2” C:\server2\run.cmd +exec server.cfg +exec smsp.cfg +exec smst.cfg
timeout /t 7200
taskkill /f /im FXServer.exe
@echo Server Shutdown Successfully.
timeout /t 2 >nul
taskkill /f /fi “server2”
@echo Server Is Restarting Now.
timeout /t 10
goto loop

Would that work if my directory is server2?

It seems i get an error with this below

:loop
@echo Clearing Server Cache Files
timeout /t 3
cd %server2%
timeout /t 1 >nul
@echo off
cls
@echo Hit Enter In This Window To Restart Server Immediately, Keep This Window Open For Automatic 2 Hour Server Restarts.
start “server2” C:\server2\run.cmd +exec server.cfg +exec smsp.cfg +exec smst.cfg
timeout /t 7200
taskkill /f /im FXServer.exe
@echo Server Shutdown Successfully.
timeout /t 2 >nul
taskkill /f /fi “server2”
@echo Server Is Restarting Now.
timeout /t 10
goto loop

There we go i appreciate the help.

In history, maybe during the CitMP times yes, but FXServer is able to adjust and handle caches and resource updates properly. Clearing caches constantly after every reboot is a very bad practice and can lead to more issues. Lots of people including me are able to run their servers constantly for a very long time in a stable manner without the need of clearing cache everytime.

2 Likes