DEV Community

Discussion on: How to simplify cron monitoring with a simple bash trick

Collapse
 
leojpod profile image
leojpod

You could couple that with an error reporting as well:

task a || curl on.error.endpoint && curl on.success.endpoint

Collapse
 
geshan profile image
Geshan Manandhar

Yes

Collapse
 
leojpod profile image
leojpod

There is a funny reason here to have those things in that order. If one puts the "or report error" after the "and report success" then if the success report fails for some reason then the error report will be called.
And if for some reason the success report fails once its action has been performed (e.g. the request reaches the server but then time out or who knows what) then you would end up with a Schrödinger report in your logs: for one cron job you would have both a success and a fail log entry.