Script to monitor for new file with ext .err and size > 0 bytes and perform a action or command

Hi All,

I need to create a script to monitor a dir for new files with ext .err and also it should b a non empty files. and perform a action or command .

We have a new ETL application that runs on a linux server, every times a etl fails it creates a .err file or updates the existing .err file with the error messages. I want to catch that error or etl name in that .err file and pass it to our monitoring agent .

for eg:

if there is any new file with ext .err or a existing .err file is modified then

issues command usr/local/bin/ncalert SEV=WARN EID=1 SOURCE=APP1 COMPID=BCO_CPIT SUMMARY=' .ETL file name from that err file'

What UNIX do you have? - please run the command

uname -a 

and show us the output.

Its redhat linux

---------- Post updated at 12:10 AM ---------- Previous update was at 12:09 AM ----------

Sorry cant run now as m away from my deck replying from my mobile

Hi,
Try this one,

for [ 1 ];
do
   `find /search/path -name "*.err" -mmin -15 | xargs execute_ur_cmd_here_every_file`
   sleep 900
done

i used to sleep the script, but you can configure it in cron without using sleep with for loop.
I dont know about what you are going to do if the err file exists.

Cheers,
Ranga:-)

I assume that's supposed to be a while loop, not a for. And the command substitution doesn't seem to have any reason to be there, unless you believe that the stdout of the utility run by xargs will yield a pipeline.

Regards,
Alister