Recursive file_remove

View thread

Jakauppila

Is there any way to recursively delete files with file_remove?

I have applications logging in the following structure:

  • D:\Applogs\App1\Access-3172016.log
  • D:\Applogs\App2\Access-3162016.log

We're able to define an input and collect the logs no problem with the following definition:

<Input Access_Logs>

    Module    im_file
    
    File    "D:\\AppLogs\\Access*.log"
    
    Recursive TRUE
    
    ...

</Input>

The number of variance of apps are large, so ideally I would want to specify the schedule to delete logs with the following:

<Extension fileop>
   Module      xm_fileop
   <Schedule>
        Every     1 min
        Exec    file_remove('D:\\AppLogs\\Access-*.log', (now() - 259200 ));
   </Schedule>
</Extension>

But this looks specifically in the directory defined and looks like you cannot recursively search the directory heirarchy for the file like you can in the input.

Is there any way I can get this functionality?