Jump to content
  • 0

log-rotator.cmd


tinboye

Question

I been trying to get the log-rotator.cmd to work, but i keep getting errors, wondering if anyone knows why?

here is the script:

@echo off

:::::::::::::: CONFIG ::::::::::::::::::

:: Set your Arma3 Epoch Base installation directory. LEAVE OFF THE ENDING \    
set arma3srvpath= %ThisService_RootDirectory%

:: Set your Default server profile name. This is the name of the directory that stores your server.cfg
:: This will be used in the case that you don't launch this script without the server param.
:: Example: SC, US6, Chicago13, ect
:: DEFAULTPROFILE    
set srvname=%ThisService_commandlineprofiles%


:: Delete Original log files after they have been rotated? This keeps your logs more organized and saves space.
:: This will not work unless the server is stopped first. This option works best set to 1 when using FireDaemon's Pre/Post Service tab
set deloriglogs=1

::::::::::: ADVANCED CONFIG ::::::::::::
:: Don't touch anything below this point unless you know what your doing.

:: Setting Server Profile to Use
IF "%1"=="" (
set servername=%srvname%
) else (
set servername=%1
)

TITLE  ArmaIII Epoch %servername% Server Log Rotater

:: Set Debug Mode
set debug=1
:: Set Debug Timeout in seconds
set dbsecs=3

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::  STOP EDITING ::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: Display Debug output
if %debug% == 1 (
echo Server Name = %servername%
echo ArmaIII Server Path = "%arma3srvpath%"
timeout %dbsecs%
)

:: Set Time and Date
SET HOUR=%time:~0,2%
SET dtStamp9=%date:~-4%%date:~4,2%%date:~7,2%_0%time:~1,1%%time:~3,2%_%time:~6,2%
SET dtStamp24=%date:~-4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%_%time:~6,2%
::Make Date Stamp
if "%HOUR:~0,1%" == " " (SET dtStamp=%dtStamp9%) else (SET dtStamp=%dtStamp24%)
ECHO Todays Date and time (%date%)(%time%) / %dtStamp%
if %debug% == 1 (
timeout %dbsecs%
)

echo (%date%) (%time%) Starting Log Rotation.

:: Make the Rotated Log Directorys
if exist "%arma3srvpath%%servername%\RotatedLogs" goto maketsdir
mkdir "%arma3srvpath%%servername%\RotatedLogs"

:rotatelogs
:: Starting Log Rotation. If there are any other logs, just follow the format below, and make sure to NOT touch any of the varibles.

copy "%arma3srvpath%%servername%\A3Master_*.log" "%arma3srvpath%%servername%\RotatedLogs\%dtStamp%\A3Master_*.log"
copy "%arma3srvpath%%servername%\server_*.log" "%arma3srvpath%%servername%\RotatedLogs\%dtStamp%\server_*.log"
copy "%arma3srvpath%%servername%\arma3server_*.rpt" "%arma3srvpath%%servername%\RotatedLogs\%dtStamp%\arma3server_*.rpt"
echo (%date%) (%time%) Logs are backed up now...

echo (%date%) (%time%) Removing original log files.

del /Q /F "%arma3srvpath%%servername%\A3Master*.log"
del /Q /F "%arma3srvpath%%servername%\server*.log"
del /Q /F "%arma3srvpath%%servername%\arma3server*.log"
if %debug% == 1 (
timeout %dbsecs%
)

:: Done
exit

when i run the log-rotator.cmd i get these kind of errors

D:\TCAFiles\Users\username\21\sc\A3Master_*.log 
The filename, directory name, or volume label syntax is incorrect.
        0 file(s) copied

D:\TCAFiles\Users\username\21\sc\server_*.log 
The filename, directory name, or volume label syntax is incorrect.
        0 file(s) copied.

D:\TCAFiles\Users\username\21\sc\arma3server_*.rpt 
The filename, directory name, or volume label syntax is incorrect.
        0 file(s) copied.

and the code in the cmd is as follows

copy "%arma3srvpath%%servername%\A3Master_*.log" "%arma3srvpath%%servername%\RotatedLogs\%dtStamp%\A3Master_*.log".
copy "%arma3srvpath%%servername%\server_*.log" "%arma3srvpath%%servername%\RotatedLogs\%dtStamp%\server_*.log"
copy "%arma3srvpath%%servername%\arma3server_*.rpt" "%arma3srvpath%%servername%\RotatedLogs\%dtStamp%\arma3server_*.rpt"

do not worry about the %arma3srvpath%%servername% not being like %arma3srvpath%\%servername% as my variables within my tcadmin include the \ for the %arma3srvpath%

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Should this

:: Set your Default server profile name. This is the name of the directory that stores your server.cfg
:: This will be used in the case that you don't launch this script without the server param.
:: Example: SC, US6, Chicago13, ect
:: DEFAULTPROFILE    
set srvname=%ThisService_commandlineprofiles%

 

Be set like

::DEFAULTPROFILE

set srvname=%ThisService_RootDirectory%\SC

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...