Can we trigger an shell script on an event


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Can we trigger an shell script on an event
# 1  
Old 10-16-2008
Can we trigger an shell script on an event

Hi,
My program A updates a log called logA.

I have a shell script S that is responsible to send emails reading from the log.
I want to trigger execution of the script whenever there is an update to the log.

Thanks in advance.
# 2  
Old 10-16-2008
Hammer & Screwdriver

If you have no control of the process that writes to the log file, one approach would be the following:

a) Create a script to determine if something has happened to the log file. You might look at the last modification date/time or the number of lines in the log file.
b) This script will need to save what it last knew (to a file probably) for comparison.
c) Will need to setup this script as a cron job - running as often as you believe necessary. Do you need to know the second a log entry is made, or is hourly sufficient? The more precise you need to know, the more computer resources will be taken to determine it.
d) When script found a new entry, create your email message and use mailx or mutt or other email to send notification.
# 3  
Old 10-16-2008
if logA is dedicated to Script A means, we can make it simple.

Whenever the Script A writes to the log file.after that line call the script S to send email.
# 4  
Old 10-16-2008
MySQL

hi ,
i dont know whether i understood correctly ,

if there is an update in a log-file then u want to run a shell-script [which does something ] !!

i will do this in a simple way by running a deamon-job which keeps checking the log if increase in size then run the script S

>>>>>>>>>>>>>>
prev-size= [get the size od the file ]
start-loop
current size =[get the size of the file]
if current-size > prev-size then
execute shellscript S
else
continue
fi
end-loop
<<<<<<<<<<<<<<<<<

but this will be like writing another shell-script , i dont know is it useful 4 u or may b ur looking for some simple command for triggering
# 5  
Old 10-16-2008
UNIX and GNU/Linux do not have a builtin general purpose event mechanism/API that you could use to monitor a log file and perform actions depending on the contents of the log file. However there are any number of log monitoring utilities available. Just do a search on the Internet for "Linux watch log files"
# 6  
Old 10-16-2008
Quote:
Originally Posted by joeyg
If you have no control of the process that writes to the log file, one approach would be the following:

a) Create a script to determine if something has happened to the log file. You might look at the last modification date/time or the number of lines in the log file.
b) This script will need to save what it last knew (to a file probably) for comparison.
c) Will need to setup this script as a cron job - running as often as you believe necessary. Do you need to know the second a log entry is made, or is hourly sufficient? The more precise you need to know, the more computer resources will be taken to determine it.
d) When script found a new entry, create your email message and use mailx or mutt or other email to send notification.

unfortunately, CRON is out of question due to security issues. its the company standard. Smilie

actually the log is not updated quite often, however, the requirement is to get the notification as soon as there is an update.. few mins here & there is not an issue at all.
# 7  
Old 10-16-2008
Quote:
Originally Posted by manosubsulo
if logA is dedicated to Script A means, we can make it simple.

Whenever the Script A writes to the log file.after that line call the script S to send email.
but Program A is totally dedicated to doing something else.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Trigger executable on HMC on occurence of an event

Hi all, sadly I currently don't have any access to a HMC and I am interessted if anybody knows if there is any way to trigger an executable/script in case of incomming hardware errors etc.. I don't remember there was any such option but then my last HMC was v7.x more than 2 years ago I saw. I... (3 Replies)
Discussion started by: zaxxon
3 Replies

2. Shell Programming and Scripting

Shell script to poll a directory and stop upon an event

Need shell script to: 1/keep polling a directory "receive_dir" irrespective of having files or no files in it. 2/move the files over to another directory "send_dir". 3/the script should only stop polling upon a file "stopfile" get moved to "receive_dir". Thanks !! My script: until do... (0 Replies)
Discussion started by: iaav
0 Replies

3. Shell Programming and Scripting

Shell script to execute condition until an event occurs

I need a script to keep polling "receive_dir" directory till "stopfile" get written in the directory. This has to run despite empty directory. So far i have this but fails if receive_dir is empty with no files with "unary operator expected". Help !! #!/usr/bin/ksh until do for i... (1 Reply)
Discussion started by: iaav
1 Replies

4. Shell Programming and Scripting

Shell script trigger using http interface

Hi I have created a shell program, which takes a series of parameters as shown in the below code. Its working good from terminal. My program restorejob.sh -g <NAME> -p <Path-to-search> -r <Path-to-restore> Its working fine from bash shell. I want to extend this functionality like... (1 Reply)
Discussion started by: rakeshkumar
1 Replies

5. UNIX for Dummies Questions & Answers

shell script to trigger an other shell script

Folks, how to trigger a shell script eg " B " from shell script eg "A" and parse different arguments to the child shell script "B" - like 0 the first time the shell script "B" is triggered and 1 the next time. Shell script A -----------> launch shell script B with an args 0... (6 Replies)
Discussion started by: venu
6 Replies

6. Shell Programming and Scripting

Execute shell script from plsql trigger

Hi, I have been assigned a job which requires me to send mails from unix(Mailx) upon on certain actions triggered in the database. On insert/update of a certain field into one of the database tables the shell script present in Unix box responsible to send mail though mailx needs to be triggered... (7 Replies)
Discussion started by: hemant.bs11
7 Replies

7. Shell Programming and Scripting

How to trigger workflow manager through shell script?

I am new to siebel workflow manager. Can anyone help me regarding the shell script which will trigger siebel workflow manager. I want a sample shell script to trigger workflow manager. Thanks in advance. (2 Replies)
Discussion started by: siri_886
2 Replies

8. Shell Programming and Scripting

keypress event in shell script

Hi All, How can I trap a character press in the shell script. For eg:- I have a script runinng a infinite loops , I will need to dispay menu asking for run process of to stop process and process stauts like we do in glance I have seen the traping the signal in glance command, (8 Replies)
Discussion started by: arvindng
8 Replies

9. Shell Programming and Scripting

Trigger Shell Script from Current Script

Hello all, I'm new to shell programming and need some help. I would like to set up a step within a shell script to trigger another shell script to run, based on the highest return code generated in the current script. For example, if the highes return code value in the current script is less... (1 Reply)
Discussion started by: mmignot
1 Replies

10. Shell Programming and Scripting

Shell script call from a DB trigger

Has anybody been able to execute a shell script call from a database trigger? If so what are the steps to execute it? Do we have any specific packages in Oracle? Reards, Rahul. (1 Reply)
Discussion started by: rahulrathod
1 Replies
Login or Register to Ask a Question