7 Replies Latest reply: Dec 17, 2012 9:58 AM by user476243 RSS

    cronjob email limit

    user476243
      OEL 5

      I have a shell script setup to check a database table (log) every 2 minutes. If it finds rows it emails me (via cronjob). However, I get flooded with emails. How can I set a limit to the number of email/alerts I get.

      This could be similar to a 24/7 database that you want to check if it is down constantly via shell script (cron) and if it is down, it should email you...but when do you tell it to stop?

      Thank you.
        • 1. Re: cronjob email limit
          Catch~22
          You can setup Oracle Enterprise Manager Grid Control to send you email notifications if a database status changes or other failures occur.
          • 2. Re: cronjob email limit
            user476243
            True. But what could I do for the cronjob example?

            Thanks.
            • 3. Re: cronjob email limit
              Avi Miller-Oracle
              956685 wrote:
              I have a shell script setup to check a database table (log) every 2 minutes. If it finds rows it emails me (via cronjob). However, I get flooded with emails. How can I set a limit to the number of email/alerts I get.
              You don't, at least not natively in cron. Your script would have to count the number of times it's emailed you and do it's own limiting. You should probably consider a more robust monitoring solution like DB console in your database (assuming it's Oracle) or Nagios or ZenOss or any one of those sorts of products.
              • 4. Re: cronjob email limit
                user476243
                Yes, the database I'm using is Oracle.

                I do currently use Grid Control. It's good but what if the Grid database goes down? There go all your alerts. You would have to rely on a cronjob (or some other utility) to alert you that OEM Grid Control is down.

                Thanks for the help. I will try and tweak my script.
                • 5. Re: cronjob email limit
                  Catch~22
                  What if your email system is down?

                  I suggest to use Grid Control to setup database alerts and perhaps use a cron task to fire an email if the grid control process is not running. Setting up alerts in cron to monitor Oracle software components is not very feasible. If you use Oracle 11g, check out Oracle Restart. Oracle Restart can be configured to automatically startup and shutdown Oracle components during a system restart or after a hardware or software failure.
                  • 6. Re: cronjob email limit
                    898553
                    I'm a little weary about what you're trying to do but, if I was to do it your way, I'd have the cron job dump the output to a file, then setup a different cron to mail you that file every hour (or whenever you'd like) with a summary of the info.
                    • 7. Re: cronjob email limit
                      user476243
                      Thanks for the idea. Makes sense.

                      I will try that.