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:

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.

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:

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

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 :frowning: ) . 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.