How my sites check themselves every morning at 09:07

By Yaver Abbas / 4 Dec 2026 / 6 min read

1. The problem

I run several sites and I am one person. Before this, I found broken pages when a visitor told me, or worse, when nobody did and the traffic just dropped.

2. What runs at 09:07

Every morning at 09:07 Pakistan time, a small job on my server opens each site, checks that the home page loads, that the SSL certificate has more than 14 days left and that the sitemap answers. If anything fails, I get one short email. If everything passes, I hear nothing.

My own agency job does more: it also reads Search Console, GA4, Bing and PageSpeed, and asks Claude to spot drops. The script below is the core that you can copy today.

3. Copy it for your site

You need a server that can run a scheduled task (I use Coolify), an email API and a short script. Brevo has a free plan that is enough for alerts. The script has a comment on every step.

import os, socket, ssl, time, json
from urllib.request import Request, urlopen

SITES = ["https://example.com"]           # your sites
MIN_DAYS = 14                             # warn when the certificate is this close to expiring


def check(site):
    problems = []
    host = site.split("//")[1].split("/")[0]
    try:                                  # 1. does the home page load?
        with urlopen(Request(site, headers={"User-Agent": "site-check"}), timeout=15) as r:
            if r.status != 200:
                problems.append(f"home returned {r.status}")
    except Exception as e:
        problems.append(f"home failed: {e}")
    try:                                  # 2. how long is the SSL certificate valid?
        with socket.create_connection((host, 443), timeout=10) as s:
            with ssl.create_default_context().wrap_socket(s, server_hostname=host) as t:
                days = (ssl.cert_time_to_seconds(t.getpeercert()["notAfter"]) - time.time()) / 86400
        if days < MIN_DAYS:
            problems.append(f"certificate expires in {days:.0f} days")
    except Exception as e:
        problems.append(f"certificate check failed: {e}")
    try:                                  # 3. does the sitemap answer?
        urlopen(site + "/sitemap.xml", timeout=15).close()
    except Exception as e:
        problems.append(f"sitemap failed: {e}")
    return problems


def send(text):                           # one short email through Brevo's API
    body = {"sender": {"email": os.environ["MAIL_FROM"]}, "to": [{"email": os.environ["MAIL_TO"]}],
            "subject": "Site check: something failed", "textContent": text}
    req = Request("https://api.brevo.com/v3/smtp/email", json.dumps(body).encode(),
                  {"api-key": os.environ["BREVO_API_KEY"], "content-type": "application/json"})
    urlopen(req, timeout=15).close()


report = {s: p for s in SITES if (p := check(s))}
if report:                                # silent when everything passes
    send("\n".join(f"{s}: " + "; ".join(p) for s, p in report.items()))

4. Schedule it

09:07 in Pakistan is 04:07 UTC. Most schedulers run in UTC, so the cron line is 7 4 * * *. Set MAIL_FROM, MAIL_TO and BREVO_API_KEY as environment variables on the server, never inside the script.

  • Run it by hand once with a wrong site address, to see the failure email arrive.
  • Keep the list of sites short at first. Add one at a time.
  • A check you never see fail is a check you do not trust yet, so test the failure on purpose.

Want this running on your site?

Book a 20-minute call

Times show in your time zone. UK mornings and US East evenings are easiest.