Discussion Locked

Delete log files by age

0 helpful
11 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
On one server we have, there are 7 log file directories which contain both logs and configuration files. Each day the programs create a new log file. I haven't found a way to input the file mask (For example: C:\Gips\Log\boss.*, o:\application\alarmserver\current\log\alrmserv\socket\*.log) and delete files older than a specific date. Windows 2000 command line commands don't seem to have that ability, and neither does any program I've seen. I would like to run one program or script that would take the file masks I give it, and delete those that are older than a month. Any ideas would be helpfull.

11 replies

by cactus pete

Do you know, or are you willing to learn how Windows scripting works? It's actually a simple VBScript that you can even schedule to run...

But remember, a little knowledge can be a dangerous thing, so you need to learn more than is necessary to just create this script.

This is the only thing that prevents me from posting a sample outright... Your environment/needs can vary slightly, and too much may be deleted by accident.

Now that the disclaimer is overwith... I'd say that you can probably write 8 lines of VBS to accomplish that.

by jfrench

Could you point me to a good starting point to learning VBS? Even if I don't need it in this situation, knowing the basics of VBS will help me later.

by cactus pete

Look at his books. They were very informative and easy to follow with great examples for real world application.

Specifically, fo you, I would suggest:

Windows NT Shell Scripting and
Windows Script Host

by joseph moore

I could probably do this in a BAT file, using the FOR command.
I just need to know how the .log files are named, if they have the date in their file names or not.

by cactus pete

Do you have a big nasty date comparison, or are you thinking of just older than same day last month, or something?

by jfrench

Older than the same date last month would work. Basically these log files record every transaction through them... so if there is a problem we need to send them to our vendor so their programmers can look at them. However, these directorys have quickly grown since a single log file sometimes can be a gig in size.
*mutters* pay so much for a system and they can't even manage their own log files

by jackofalltech

There is a freeware utility called XDel that has several date-specific options. Sorry, I don't have a URL, I have it on my PC at home but not here at work.

If you can't find it, I could write a comparable program for you (free) if you're interested.

Ralph

by jfrench

I looked for XDEL... but all I found was a few pages that told me to get a subscription (paid) to the site to download, or a program called XDEL that is ment for deleting directory trees (and no documentation or command line options for it)

by cactus pete

Perhaps what you really need to an "AutoArchiver" application.

I needed that at my last job - a financial trading company. Basically, we wrote an application that would zip the log files and write them to another file/directory named by date. It was very self-contained... Unfortunately, I can't give it to you, as it belongs to that company. But I can describe it to anyone who needs to know what to reproduce...

by jfrench

I don't have the knowledge to create such a program. If someone could it would be a great help for me.

by jfrench

I'll probably buy them from amazon tonight... Not sure if I can learn that in time for this problem though.

If anyone would like to take the time to write the scripts, e-mail me and I'll send a listing of all the log file naming conventions used.

This discussion is closed to new replies.