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'
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.
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.