Set Interval for input modules


#1 casey1234

Say I wanted to run a PowerShell script on an interval using the im_exec module how would I do that?

<Input powershell>
    Module  im_exec
    Command "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
    Arg     "script goes here"
    <Exec>
       $output = $raw_event;
    </Exec>
</Input>

I can make the interval work by creating pauses in the code but then it appears as though the script process would run forever which is undesirable for efficiency and stability reasons. Is there a way to run the code on a interval, say every fifteen minutes?

Thoughts?

Thanks in advance!!

#3 manuel.munozDeactivated Nxlog ✓
#1 casey1234
Say I wanted to run a PowerShell script on an interval using the im_exec module how would I do that? <Input powershell> Module im_exec Command "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" Arg "script goes here" <Exec> $output = $raw_event; </Exec> </Input> I can make the interval work by creating pauses in the code but then it appears as though the script process would run forever which is undesirable for efficiency and stability reasons. Is there a way to run the code on a interval, say every fifteen minutes? Thoughts? Thanks in advance!!

Hi Casey!

Maybe what you want to use is the Schedule directive.

Please take a look to reference manual, section "2.3.2. Schedule":

<Input in>
  Module im_tcp
  Port 2345
  <Schedule>
  Every 1 sec
  First 2010-12-17 00:19:06
  Exec log_info("scheduled execution at " + now());
  </Schedule>
  <Schedule>
  When 1 */2 2-4 * *
  Exec log_info("scheduled execution at " + now());
  </Schedule>
</Input>