自动化的脚本来压缩IIS日志? [英] Automated script to zip IIS logs?

查看:355
本文介绍了自动化的脚本来压缩IIS日志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个脚本/批次将一堆了我日常的IIS日志,并按月拉链起来。

I'd like to write a script/batch that will bunch up my daily IIS logs and zip them up by month.

ex080801.log这是前格式* YYMMDD * .LOG

ex080801.log which is in the format of ex*yymmdd*.log

ex080801.log - ex080831.log被压缩和日志文件中删除

ex080801.log - ex080831.log gets zipped up and the log files deleted.

我们这样做的原因是因为过重的网站一天的日志文件可能是500MB到1GB,所以我们压缩它们的COM $ P $ 98%psses他们和转储真正的日志文件。我们使用webtrend分析日志文件,它能够读取到一个zip文件。

The reason we do this is because on a heavy site a log file for one day could be 500mb to 1gb so we zip them up which compresses them by 98% and dump the real log file. We use webtrend to analyze the log files and it is capable of reading into a zip file.

有没有人对如何编写脚本任何想法或愿意分享一些code?

Does anyone have any ideas on how to script this or would be willing to share some code?

推荐答案

您将需要一个命令行工具来压缩的文件。我建议的7-Zip 这是免费的,易于使用。自包含的命令行版本(7za.exe)是最便携的选择。

You'll need a command line tool to zip up the files. I recommend 7-Zip which is free and easy to use. The self-contained command line version (7za.exe) is the most portable choice.

下面是这将压缩日志文件,然后删除它们的两行批处理文件:

Here's a two-line batch file that would zip the log files and delete them afterwards:

7za.exe a -tzip ex%1-logs.zip %2\ex%1*.log
del %2\ex%1*.log

第一个参数是4位数的同比和月,第二个参数是路径到包含日志的目录。例如: ziplogs.bat 0808 C:\\日志

这是可能得到更详细的(即搜索文件名以确定哪个归档个月)。你可能想看看在Windows FINDSTR 命令与常规的前$ P $搜索输入文本pssions。

It's possible to get more elaborate (i.e. searching the filenames to determine which months to archive). You might want to check out the Windows FINDSTR command for searching input text with regular expressions.

这篇关于自动化的脚本来压缩IIS日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆