赞
踩
::Author: 尤鹏
::Desc: AutoClearLogFiles
::2022年10月01日09:03:12
:: 清理日志文件
@echo off
title ClearIISLogFiles
:: 设定log文件位置
set log_dir=“C:\MES_API_LOG”
:: 保留日志天数
set bak_dat=7
::设置日期变量
set todays=%date:0,4%%date:5,2%%date:~8,2%
::输出开始日志
echo SERVER: %computername% ,USERNAME: %username% ,DATE: %date%%time% ,DELTE%log_dir%%bat_dat% LOG IS START! >>C:\BACK\logclear%todays%_logclear.log
:: 删除日志文件
forfiles /p %log_dir% /S /M *.txt /D -%bak_dat% /C “cmd /c echo Deleting @relpath File… & echo. & del @file” >>C:\BACK\logclear%todays%_logclear.log
:: 设定log文件位置, 再次设定变量时,需要重新set 不能直接引用变量
set log_dir=“C:\MESAPI”
:: 删除日志文件
forfiles /p %log_dir% /S /M *.txt /D -%bak_dat% /C “cmd /c echo Deleting @relpath File… & echo. & del @file” >>C:\BACK\logclear%todays%_logclear.log
::输出结束日志
echo SERVER: %computername% ,USERNAME: %username% ,DATE: %date%%time% ,DELTE%log_dir%%bat_dat% LOG IS END! >>C:\BACK\logclear%todays%_logclear.log
end
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。