Python
Using requests
import requests PING_URL = "https://watchcron.com/ping/your-uuid" # Signal start requests.get(f"{PING_URL}/start", timeout=10) try: # Your work here run_backup() # Signal success requests.get(PING_URL, timeout=10) except Exception as e: # Signal failure with error message requests.post(f"{PING_URL}/fail", data=str(e), timeout=10) raise
Using urllib (no dependencies)
import urllib.request PING_URL = "https://watchcron.com/ping/your-uuid" urllib.request.urlopen(PING_URL, timeout=10)
Reusable decorator
import functools, requests def monitor(ping_url): def decorator(func): @functools.wraps(func) def wrapper(*args, **kwargs): requests.get(f"{ping_url}/start", timeout=10) try: result = func(*args, **kwargs) requests.get(ping_url, timeout=10) return result except Exception: requests.get(f"{ping_url}/fail", timeout=10) raise return wrapper return decorator @monitor("https://watchcron.com/ping/your-uuid") def nightly_backup(): # Your logic here ...