samt2497 Posted August 12, 2012 Share Posted August 12, 2012 (edited) Hola, recientemente fue que vi un pequeño batch sencillo para mantener el servidor online aqui les proporciono uno mas completico para los curiosos que ademas de mantener el servidor on guarda registro de cuando se apago y clasifica los logs por fecha... Solo para windows! @ECHO OFF TITLE SXRestarter MTA-SA by samt2497 SET opcion_logs=1 SET logmta=mods\deathmatch\logs\server.log SET freinicios=reinicios.log SET server="MTA Server.exe" SET conteo=0 IF NOT EXIST %server% ( COLOR 0C ECHO %server% no encontrado ECHO Presione cualquier tecla para reintentar PAUSE > NUL GOTO EOF ) :START CLS & ECHO. SET hh=%time:~0,2% IF %hh% LSS 10 SET hh=0%time:~1,1% SET msg=[%date%][%hh%:%time:~3,5%] Server IF %conteo% EQU 0 (SET msg=%msg% iniciado.) ELSE SET msg=%msg% reiniciado [%conteo%x]. ECHO %msg% & ECHO %msg%>> %freinicios% SETLOCAL ENABLEEXTENSIONS for /f "tokens=1-4 delims=:,.-/ " %%i in ('echo %time%') do ( set 'hh'=%%i set 'mm'=%%j set 'ss'=%%k set 'ff'=%%l) ENDLOCAL & SET v_Hour=%'hh'%& SET v_Minute=%'mm'%& SET v_Second=%'ss'%& SET v_Fraction=%'ff'% set timestring=%V_Hour%%V_Minute%%v_Second% set v_day= set v_month= set v_year= SETLOCAL ENABLEEXTENSIONS if "%date%A" LSS "A" (set toks=1-3) else (set toks=2-4) for /f "tokens=2-4 delims=(-)" %%a in ('echo:^|date') do ( if "%%a" GEQ "A" ( for /f "tokens=%toks% delims=.-/ " %%i in ('date/t') do ( set '%%a'=%%i set '%%b'=%%j set 'yy'=%%k ) ) ) if %'yy'% LSS 100 set 'yy'=20%'yy'% set Today=%'yy'%-%'mm'%-%'dd'% ENDLOCAL & SET v_year=%'yy'%& SET v_month=%'mm'%& SET v_day=%'dd'% set datestring=%V_Year%%V_Month%%V_Day% if %V_Month%==01 set MN=Enermo if %V_Month%==02 set MN=Febrero if %V_Month%==03 set MN=Marzo if %V_Month%==04 set MN=Abril if %V_Month%==05 set MN=Mayo if %V_Month%==06 set MN=Junio if %V_Month%==07 set MN=Julio if %V_Month%==08 set MN=Agosto if %V_Month%==09 set MN=Septiembre if %V_Month%==10 set MN=Octubre if %V_Month%==11 set MN=Noviembre if %V_Month%==12 set MN=Diciembre echo %datestring% Set savename=%V_Hour%hours_%V_Minute%minutes IF NOT EXIST logs MD logs IF NOT EXIST logs\%V_Year% MD logs\%V_Year% IF NOT EXIST logs\%V_Year%\%MN% MD logs\%V_Year%\%MN% IF NOT EXIST logs\%V_Year%\%MN%\%V_Day% MD logs\%V_Year%\%MN%\%V_Day% IF %opcion_logs% EQU 1 ( ECHO %msg%>> logs\%V_Year%\%MN%\%V_Day%\%savename%.log TYPE %logmta%>> logs\%V_Year%\%MN%\%V_Day%\%savename%.log FOR /L %%i IN (1,1,4) DO ECHO.>> logs\%V_Year%\%MN%\%V_Day%\%savename%.log DEL %logmta% ) GOTO NEXT :NEXT SET /A conteo+=1 CALL %server% GOTO START :EOF Edited August 12, 2012 by Guest 1 Link to comment
Alexs Posted August 12, 2012 Share Posted August 12, 2012 Buen Aporte, Toma una Galleta! Link to comment
BorderLine Posted August 12, 2012 Share Posted August 12, 2012 Interesante. Exelente aporte man Link to comment
Otto Posted August 16, 2012 Share Posted August 16, 2012 Hermoso, pero para superar a Alex, yo te hice un pastel en buena calidad. Link to comment
Soren Posted August 17, 2012 Share Posted August 17, 2012 Exceletne Gracias Samt lo usare para GPC Ahora Alexs y Otto me quedan cortos Link to comment
Plate Posted August 20, 2012 Share Posted August 20, 2012 Jajaja muy bueno muchas gracias! Link to comment
Alexs Posted August 24, 2012 Share Posted August 24, 2012 Esta hecho para estar en conjunto al servidor, la IP no deberia influir. Link to comment
iFoReX Posted August 25, 2012 Share Posted August 25, 2012 Ook como seria la extension ? Link to comment
Alexs Posted August 25, 2012 Share Posted August 25, 2012 Ook como seria la extension ? .Bat Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now