Delete log files older than 20 Days
Delete log files older than 20 Days was created by Emiliano
Hello
I have a requirement to delete data transformation logs older than 20 days old.
Can I do this with Visual Importer ETL
Emiliano
I have a requirement to delete data transformation logs older than 20 days old.
Can I do this with Visual Importer ETL
Emiliano
8 years 11 months ago
#4640
Please Log in or Create an account to join the conversation.
Replied by admin on topic Re: Delete log files older than 20 Days
Hello
Something like this should do
var i: integer;
Rec : TSearchRec;
Attr : integer;
SearchDirectory,Mask : string;
begin
SearchDirectory:='c:\';
Mask:='*.csv';
Attr := faReadOnly+faHidden+faArchive+faAnyFile;
if FindFirst(SearchDirectory+Mask,Attr,Rec) = 0 then
try
repeat
if ((Rec.Name='..') or (Rec.Name='.'))=false then
begin
if FormatDateTime('YYYY-MM-DD',FileDateToDateTime(FileAge(SearchDirectory+Rec.Name)))<FormatDateTime('YYYY-MM-DD',now-30) then
DeleteFile(SearchDirectory+Rec.Name);
end;
until FindNext(Rec) <> 0;
finally
FindClose(Rec);
end;
result:=true;
end;
George
Something like this should do
var i: integer;
Rec : TSearchRec;
Attr : integer;
SearchDirectory,Mask : string;
begin
SearchDirectory:='c:\';
Mask:='*.csv';
Attr := faReadOnly+faHidden+faArchive+faAnyFile;
if FindFirst(SearchDirectory+Mask,Attr,Rec) = 0 then
try
repeat
if ((Rec.Name='..') or (Rec.Name='.'))=false then
begin
if FormatDateTime('YYYY-MM-DD',FileDateToDateTime(FileAge(SearchDirectory+Rec.Name)))<FormatDateTime('YYYY-MM-DD',now-30) then
DeleteFile(SearchDirectory+Rec.Name);
end;
until FindNext(Rec) <> 0;
finally
FindClose(Rec);
end;
result:=true;
end;
George
Mike
8 years 11 months ago
#4641
Please Log in or Create an account to join the conversation.
Replied by keiooz on topic Re: Delete log files older than 20 Days
What actually happens if you won't delete your logs older than 20 days?
8 years 10 months ago
#4707
Please Log in or Create an account to join the conversation.