From 7a95abc6c035be215796848caf571de512b947f9 Mon Sep 17 00:00:00 2001 From: Fredrik Eriksson Date: Mon, 8 Jul 2019 21:14:55 +0200 Subject: [PATCH] troubleshooting... --- cronwrapper/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cronwrapper/__init__.py b/cronwrapper/__init__.py index 28df779..254d1a0 100755 --- a/cronwrapper/__init__.py +++ b/cronwrapper/__init__.py @@ -217,7 +217,9 @@ def main(): if previous_runs: # Not the first failure... oldest = datetime.datetime.fromtimestamp(min(previous_runs.values())) - if now-oldest > datetime.timedelta(seconds=args.warn_interval): + delta = datetime.timedelta(seconds=args.warn_interval) + diff = now-oldest + if diff > delta: # we have failed for a long time, send a report print("Cronjob is still failing after {} seconds ({} failures)\n".format(args.warn_interval, len(previous_runs))) print_runs(previous_runs.keys())