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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to monitor for new file with ext .err and size > 0 bytes and perform a action or command
# 1  
Old 03-07-2012
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'
# 2  
Old 03-07-2012
What UNIX do you have? - please run the command
Code:
uname -a

and show us the output.
# 3  
Old 03-07-2012
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
# 4  
Old 03-07-2012
Hi,
Try this one,
Code:
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:-)
# 5  
Old 03-07-2012
Quote:
Originally Posted by rangarasan
Hi,
Try this one,
Code:
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
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk script to perform an action similar to vlookup between two csv files in UNIX

Hi, I am new to awk/unix and am trying to put together an awk script to perform an action similar to vlookup between the two csv files. Here are the contents of the two files: File 1: Date,ParentID,Number,Area,Volume,Dimensions 2014-01-01,ABC,247,83430.33,857.84,8110.76... (9 Replies)
Discussion started by: Prit Siv
9 Replies

2. Shell Programming and Scripting

Perform an action if certain text exist in output (PERL)

Hello, I'm attempting to write a tool that checks an IP address for existing PTR records then if there are no PTR records does a ping to see if it response. Then if there is no response, it should print a message saying This is what I have so far. #!/usr/bin/perl $nxdomain =... (4 Replies)
Discussion started by: spartan22
4 Replies

3. Shell Programming and Scripting

Error PHP Fatal error: Allowed memory size of 67108864 bytes exhausted(tried to allocate 401 bytes)

While running script I am getting an error like Few lines in data are not being processed. After googling it I came to know that adding such line would give some memory to it ini_set("memory_limit","64M"); my input file size is 1 GB. Is that memory limit is based on RAM we have on... (1 Reply)
Discussion started by: elamurugu
1 Replies

4. Shell Programming and Scripting

shell script - search a file and perform some action

hi, i have a service on unix platform, it will generate traces in a particular folder i want to check using shell script if traces exist, then perform some action else continue to be in loop. filename is service.tra can you please help? thanks (4 Replies)
Discussion started by: gauravah
4 Replies

5. Shell Programming and Scripting

How to perform action on newest line in log using tail?

I don't quite know what I'm doing, so this simple script is proving a challenge. Here is some pseudo code that doesn't work yet: if tail -1 "WORKING.txt" >/dev/null | egrep "^NMBR=*" > /dev/null then curl -k 'http://www.myserver.com/log.cgi?input=$?' echo "hi there" fi Purpose:... (3 Replies)
Discussion started by: dihewidd
3 Replies

6. Shell Programming and Scripting

Need help in searching 2 files for strings then perform an action

I have 2 files. I basically want to search both of them to see if the 1st column ($1) matches and if it matches then check to see if the 2nd column ($2) matches, then execute some code showing the results of the matches. File 1: AAA 123 misc blah BBB 456 CCC 789 File 2: ... (2 Replies)
Discussion started by: streetfighter2
2 Replies

7. Shell Programming and Scripting

Perform action file name written to the pipe

Hello, I have a script that monitors files uploaded via ftp. After a successful upload, the file name is written to the pipe. There is another program that reads this pipe and allows automatically run any program or script ( say test.sh ) to process the newly uploaded file. cat test.sh... (2 Replies)
Discussion started by: fed.linuxgossip
2 Replies

8. UNIX for Dummies Questions & Answers

file size in bytes is different in ftp and local pc

Hi how can it be that say i have text (xls) file that is 661 bytes when i upload it to Solaris ftp its becomes 650 byes and when i downloading it back its again 661 bytes both in my local pc and Solaris ftp the file remains not corrupted and valid (2 Replies)
Discussion started by: umen
2 Replies

9. Shell Programming and Scripting

Email message if file size > 0 bytes

I want to create a script that emails a file created by Informix Ace if the file size is > 0. It is a list of exceptions. No exceptions...no message This does not work: THESIZE=`ls -lA /tmp/ds_treo.txt | awk -F' ' '{print $5}'` if then (cat $DSDIR/ds_treo.txt) | mail -s "Treo... (1 Reply)
Discussion started by: poste_d_ordure
1 Replies
Login or Register to Ask a Question