Oct
15
Tip: Getting Unix command output and status in your email
I have a scheduled script that refreshes some of my materialized views but sometimes these operations could fail if the database backup takes too long or an unexpected condition presents. This led me to think of sending the output of my refresh procedures to my email or my team’s listserv, here are sample versions of my scripts:
daily_mview_refresh.sql: |
|
daily_mview_refresh.sh: |
|
Something to have in mind would be to incorporate appropriate error handling in the stored procedures being called and also providing some output that would indicate progress through the materialized view refresh process. In the scripts I actually use I also collect statistics and rebuild some indices, each view is refreshed in a different procedure as to contain any errors and allow the remaining views to be built anyway.