Vijay
Vijay

Reputation: 67291

Monitor the data in a table

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.

Upvotes: 0

Views: 86

Answers (2)

Aaron Digulla
Aaron Digulla

Reputation: 328754

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 &.

Upvotes: 0

tpdi
tpdi

Reputation: 35171

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.

Upvotes: 2

Related Questions