所以我正在尝试制作一个脚本,当它崩溃时将杀死我的gmod服务器,但是我遇到的问题是当/如果我的服务器崩溃,它不会关闭服务器应用程序。它仍然被认为正在运行,并且页面处于打开状态,如果保持打开状态并继续运行,则服务器将保持关闭状态,并且将占用我的cpu内存,而实际上什么也没做:
基本上,我真的想编写一个批处理文件,如果它的磁盘使用率达到0-0.1MB / s,它将杀死我的服务器应用程序srcds.exe。到目前为止,这是我所做的事情,该脚本旨在在关闭服务器后重新打开服务器:
::BATCH FILE IS CREATED BY DOOKIS::
@Echo off
echo Batch File Script Was Created By Dookis!
echo ...
:Start
timeout 3
echo [SCRIPT EXECUTE]
echo -------------------------------------------------------------------------------------------
echo Program terminated at %Date% %Time% with Error %ErrorLevel% >> "C:\Users\BZCdo\OneDrive\Desktop\SteamCMD (UPDATED)\package\sandboxserver - Tas (UNSTABLE)\hello.log"
echo Press Ctrl-C if you don't want to restart automatically
timeout 8
echo ----------
echo Checking server stats...
taskkill /im "IMAGENAME eq srcds.exe" /fi "STATUS eq NOT RESPONDING" ::THIS IS THE PART OF CODE I WANT TO CLOSE MY SERVER WITH BUT IT ISN'T WORKING :P
ping -l 0 -n 1 localhost
timeout 2
echo ----------
tasklist /FI "IMAGENAME eq srcds.exe" 2>NUL | find /I /N "srcds.exe">NUL
if "%ERRORLEVEL%"=="1" echo %Date% %Time% Server is not running, starting server now...
if "%ERRORLEVEL%"=="1" start srcds.exe -console -game "garrysmod" +exec "server.cfg" +gamemode sandbox +map gm_bigcity_improved +maxplayers 13 -sv_cheats 1 +host_workshop_collection 1682083244
if "%ERRORLEVEL%"=="0" echo %Date% %Time% Server Is Running
echo -------------------------------------------------------------------------------------------
echo [SCRIPT END]
goto Start