Sunday, January 18, 2009

Logfile Maintenance

Keep logfile sprawl on your servers in check with the below script. A bit of a hack; it could likely use some cleanup. Customize the aFolders array for a list of directories to recurse. Customize sFilePattern as a regular expression to match the logfiles you see on your servers.

The script accepts an argument for the number of days. Any matching files that are older than this number of days are targets for deletion.

As with all file deletion scripts, the potential for danger is high. Use the 2nd argument of TEST to be sure of the intended results.

I install the script as a scheduled task on our servers, wrapped in a CMD file. It even updates itself at each run from Amazon AWS. More on that later.


PurgeLogs.vbs.txt

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.