We are running a cron job on our website and which is doing very important work on our server with database. If that cron job fails we need to be notified so that we'll know that the work it needs to do is not done.
Any way to do it if cron doesn't runs.
Server already sends an email as soon as that cron runs but we can't have tons of emails everyday and if cron runs every 5 minutes we won't be able to track an email if it doesn't runs, that's why want to be able to track the failure of cron.
You could designate a secondary computer as a "listener". Set up a database (on either machine) and have the cron job write a row to that database when it starts (including a date-stamp). Then schedule another cron job on the secondary machine which periodically checks this database to see when the last time the primary cron job ran. If it's been more than X amount of time then the secondary cron job would send an email to you to notify you that the primary script never ran.
Note: you could also just use a single file that both machines have write-access to, and record the last-run timestamp in there, but the nice thing about the database approach is that is serves as a query-able log of all cron activity.