开发者

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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜