自己搭建的windows服务器 32g超大杯也架不住服务端里的内存泄漏! 下面送给大家一套定时重启和备份的bat脚本
[Bash shell] 纯文本查看 复制代码 set "palworld_path=C:\Program Files (x86)\Steam\steamapps\common\PalServer"#你服务端的位置
set "backup_path=C:\Users\Administrator\Desktop\backup"#备份保存目录
set interval=10800 #重启+备份的建个时间
:loop
echo [%date% %time%] Backup server data...
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set datetime=%%a
set datestamp=%datetime:~0,8%
set timestamp=%datetime:~8,6%
set year=%datestamp:~0,4%
set month=%datestamp:~4,2%
set day=%datestamp:~6,2%
set hour=%timestamp:~0,2%
set minute=%timestamp:~2,2%
set second=%timestamp:~4,2%
set foldername=%year%-%month%-%day%_%hour%-%minute%-%second%
xcopy "%palworld_path%\Pal\Saved" "%backup_path%\Backup_%foldername%" /E /H /C /I
echo [%date% %time%] Restart server...
taskkill /f /im "PalServer-Win64-Test-Cmd.exe" 2>nul
start "" "%palworld_path%\PalServer.exe"
echo [%date% %time%] Server restarted!
timeout /t %interval%
goto loop
因为存档会莫名其妙的炸档 我这边又写了个没10分钟保存一次的脚本配合使用 如果炸档了 替换即可
[Bash shell] 纯文本查看 复制代码 @echo off
set "palworld_path=C:\Program Files (x86)\Steam\steamapps\common\PalServer"
set "backup_path=C:\Users\Administrator\Desktop\backup"
:backup
echo [%date% %time%] Backup server data...
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set datetime=%%a
set datestamp=%datetime:~0,8%
set timestamp=%datetime:~8,6%
set year=%datestamp:~0,4%
set month=%datestamp:~4,2%
set day=%datestamp:~6,2%
set hour=%timestamp:~0,2%
set minute=%timestamp:~2,2%
set second=%timestamp:~4,2%
set foldername=%year%-%month%-%day%_%hour%-%minute%-%second%
xcopy "%palworld_path%\Pal\Saved" "%backup_path%\Backup_%foldername%" /E /H /C /I
echo [%date% %time%] Backup completed!
timeout /t 5 #单位是秒
goto backup
|