Hi all,
My requirement is to write a shell script to send an email alert when the DB2 particular table is not getting inserted with any data more than 2 hours. Have to compare the current date (Linux server date ) with the last modified date time, if the time is more than 2 hours have to send an email alert.
Kindly anyone please guide me to achieve this. Let me know if any details required further.
Hello. This forum is mostly for a collaboration efforts. How experienced are you with Unix/Linux command line /shell scripting? What have you tried so far? Post your code, add questions for its particular parts (that you're not sure of) and we'll come up with some possible hints to guide you through implementation of a correct solution.
1 Like
The hard part is determining when the table data is "inserted".
If this is strictly "inserted", then a periodic DB2 query on the number of records should be very cheap to do, and any increase will be obvious.
If rows can be both deleted and inserted, you will see that activity unless those actions balance exactly over the period.
If you wish to detect data changes (e.g. column updates), then a full data comparison might be necessary, and that would most likely be prohibitive. If you have control over the database, you might consider whether you can add a new one-row table that is updated in SQL with the last time of every action on the main table as part of the same commit, and just check that single record periodically.
Most databases log all activity for audit purposes (with timestamps). So I would probably suggest monitoring additions to such a log file at frequent intervals. You might need to cope with automatic rollovers and maybe non-text record formats.
Sending an email in response to an event is a well-known action. Detecting that event reliably is best done first as a separate problem, with plenty of diagnostics.
If you can consider which technique might be easiest for you to implement, we can zone on on a solution.
2 Likes