WatchDirectory Forum
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl
watchDirectory forums >> How to... >> Use WD to move log files to Archive location
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl?num=1126674974

Message started by jimaus on Sep 14th, 2005 at 7:16am

Title: Use WD to move log files to Archive location
Post by jimaus on Sep 14th, 2005 at 7:16am
Gert,
I would like to use WD to move log files, that are constantly updated by running apps, to a location for archive.
I would trigger WD to look at a location once a day and move the file, renaming it with a "filename_date_time.log" file name.

Is this possible?

Cheers

Jim

Title: Re: Use WD to move log files to Archive location
Post by Gert on Sep 14th, 2005 at 8:16am
I don't think you need to use WD for that. Just create a .bat script that does the move and "schedule" it using the AT command or "scheduled tasks" (control panel).

The script would look something like this:

@echo off
move c:\logs\thelogfile.log "d:\archive\thelogfile_%date%.log"


if you get a lot of "file in use" errors when you use the above (because other processes are writing to it), you will need a loop to retry:


@echo off
:TryAgain
move c:\logs\thelogfile.log "d:\archive\thelogfile_%date%.log"
if %errorlevel% neq 0 goto :TryAgain


Gert

WatchDirectory Forum » Powered by YaBB 2.5.2!
YaBB Forum Software © 2000-2017. All Rights Reserved.