Trigger functionality in Unix


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Trigger functionality in Unix
# 1  
Old 08-17-2012
Trigger functionality in Unix

Hi,

I want a script , which searches the log for the term/phrase "JFSnapshotService::systemSnapshot: Starting data capture. This may take awhile depending upon system workload." and if there is some logging like this, it has to mail me that this data capture process is happening.,

Below is the sample log. The problem is the logs are getting generated for other process also so with timestamp as condition it should search for this term, the script will be scheduled to run every 15/30 minutes. So the logic should be that script should search the logs from the timestamp it has previously run to that current time.

Sample log:
Code:
2012 Aug 07 00:00:10 27394 12 5 JFSnapshotService::systemSnapshot: Starting data capture. This may take awhile depending upon system workload.
2012 Aug 07 06:22:54 27394 41 3 JFEauthManager::verifyEauth: eauth len=10 failed; rc=0
2012 Aug 08 22:24:13 27394 4 3 JFInstanceManager::applyPolicy_ (): Failed to remove flow ID 1722358.
2012 Aug 08 23:24:14 27394 4 3 JFInstanceManager::applyPolicy_ (): Failed to remove flow ID 1722365.
2012 Aug 09 00:00:10 27394 12 5 JFSnapshotService::systemSnapshot: Starting data capture. This may take awhile depending upon system workload.


Last edited by Franklin52; 08-17-2012 at 06:29 AM.. Reason: Please use code tags for data and code samples
# 2  
Old 08-17-2012
Instead of a script that runs every some minutes, why don't you parse in real time the logfile, so that you can send a message as soon as the phrase is read, every time it is read?

In bash (please, always write what your OS and your shell are) something like:
Code:
string="JFSnapshotService::systemSnapshot: Starting data capture. This may take awhile depending upon system workload."
tail -f logfile | while IFS= read -r line; do
if grep "$string" <<<$line &>/dev/null; then
{ do your stuff or send your messages ; }
fi
done

--
Bye
# 3  
Old 08-17-2012
Hi Lem,

Thanks for your reply,We use Solaris and ksh.

My doubt is how to parse in real time. There is no script existing that creates this log, there is a Windows component whose logs are directed to this server ( Not sure of configurations of that component Smilie ) . That is why i thought of creating a script that executes every 15/30 minutes to check the logs for this particular term and send us a mail.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Zip -r Functionality

Hi , I've written the following code to zip the big file $dir_temp ="/home/etc/hst zip -r $dir_temp/file_nm.zip $dir_temp/file_nm The zip file has been created . When I try to UNZIP the file with the following command unzip file_nm.zip The file got unzipped but created in the... (3 Replies)
Discussion started by: smile689
3 Replies

2. Shell Programming and Scripting

Source trigger in Unix shell

Hi All, Is ther any way to write the script with source trigger ? To trigger the script on particular time we have crontab. Similarly in a path, when a file comes particular script has to run. Thanks:) (7 Replies)
Discussion started by: jesu
7 Replies

3. Shell Programming and Scripting

Pipe Functionality

Hi, I am trying to emulate the '|' functionality through pipe function call. I am passing the o/p of exec in parent as input to the exec in child. The buf is readin the o/p but the exec in child is not working. Can somebody checkout the code and point where am i going wrong or missing something.... (3 Replies)
Discussion started by: amejoish
3 Replies

4. Shell Programming and Scripting

Update trigger for unix file (solaris)

Hello, from log error file of process that i's updating in append mode, i need to capture the new entries for every day. How i can know and save only the new errors? This it's a sample of error log file (oas report server engine) thanks and regards Fran (2 Replies)
Discussion started by: fran61
2 Replies

5. UNIX for Advanced & Expert Users

Functionality of ant build and ant deploy unix commands

I have made some code changes in the corresponding java file for date formatting purpose so that it supports upgraded sybase version from 12.6 to 12.7 and have build the code and deployed using the following UNIX commands. ant build ant deploy. "ant build" executes the build.xml which is... (1 Reply)
Discussion started by: vmpcit
1 Replies

6. Shell Programming and Scripting

Trigger whoever logged in sqlplus through UNIX

We had a requirement like we should find the user whoever logged into sqlplus through UNIX automatically. For that we should write a script and store the result in file. we will get that user manually by using WHO command. can anybody help me how to trigger? I tried many commands beyond... (1 Reply)
Discussion started by: siri_886
1 Replies

7. UNIX for Dummies Questions & Answers

using functionality in another ksh

i have a function defined in one ksh i want to use the same functionality in another ksh i am using . ../<ksh name> but it is not picking that functionality what i have to do for the same (2 Replies)
Discussion started by: trichyselva
2 Replies

8. UNIX for Advanced & Expert Users

Need Help with Unix/AIX functionality

I'll start this out by saying that I'm super-new to UNIX and need some help. My setup is as follows: I am currently running 3 UNIX boxes, 2 application servers and 1 db server. The first application server is my production box, the second application server is my test box, and the db server... (1 Reply)
Discussion started by: dkeaton
1 Replies

9. UNIX for Dummies Questions & Answers

How to send a trigger file from Unix to Windows

I need to send a file from a Unix box to a Windows sever to kick off a Crystal Reports job. Any good ideas how to do this? Can it be done with FTP? (0 Replies)
Discussion started by: robw95
0 Replies

10. Shell Programming and Scripting

Sed functionality

I have a few xml files and I want to input say 5 parameters within each file. is it possible to do so with sed? <parameter>A</parameter> <parameter>B</parameter> .... .... And so on. These parameters are meant to go in just inside: <?xml... (2 Replies)
Discussion started by: collern2
2 Replies
Login or Register to Ask a Question