views:

53

answers:

2

How to write a shell script/process which runs like a daemon on Unix and continuously monitors a field in the table and sleeps for 30 sec's. The field value will regularly increase to a maximum value and my process/script which is monitoring will provide a simple select query output to a log file. any approach is preferred.

+2  A: 

Write a trigger on the table; on the value you care about, log it to another table; select from the other table at your leisure.

tpdi
A: 

This script will do:

#!/bin/bash
log=...your-log-file...

while true; do
    runQueryHere >> log
    sleep 30
done

Use the command line interface of your DB to run the query.

Run the script with script & to make it a background process. If it terminates when you log out, use nohup script &.

Aaron Digulla