windows服务器日志压缩及清理

1.下载地址

logrotate下载地址

2. 解压 配置logrotate.conf文件

# sample logrotate configuration file

# use date as a suffix of the rotated file
dateext

# uncomment to enable compression of rotated log files
compress

# this example will rotate the c:\test.log file daily and keep 5 rotations.
# there is also an example prerotate script that will print the current time and the parameter passed to it (which is the path to the log file)
#C:\test.log {
#	rotate 5
#	daily
#	prerotate
#		@echo off
#		echo This is a test
#		echo parameter pass %1
#		VER | TIME > TEMP.BAT
#		ECHO SET TIME=%%3>CURRENT.BAT
#		DEL TEMP.BAT
#		DEL CURRENT.BAT
#		ECHO It's %TIME% now
#	endscript
#}

"C:\demo\nginx\nginx-1.20.2\logs\*.log" {
	daily
    rotate 10
    missingok
	copytruncate
	compress
	size 10M
	noolddir
	dateext
	dateformat .%d-%s
}


"C:\demo\appresources\logs\*\*.log" {
	daily
    rotate 10
    missingok
	copytruncate
	compress
	size 10M
	noolddir
	dateext
	dateformat .%d-%s
}

3.清理脚本 保留30天

3.1创建cleanLog.bat

# 在操作里面配置 本示例中是把exe文件与conf放在同一目录下
forfiles /p C:\demo\appresources\logs /s /d -30 /m *.* /c "cmd /c del /q /f @path"
forfiles /p C:\demo\nginx\logs /s /d -30 /m *.* /c "cmd /c del /q /f @path"

4.配置计划任务

5.参考资料

windows 下的 apache 日志如何进行分割配置?
logrotatewin
linux logrotate 配置说明

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值