Python Script Monitoring

Know when a scheduled Python script stops checking in.

Add a heartbeat after your Python job’s required work succeeds. Keep cron or your existing scheduler, then verify a real scheduled run and an alert destination.

5 monitors free · No credit card · Verify a real scheduled run

A script that never starts cannot report its own exception.

Your script may work in a terminal while cron uses a different interpreter, working directory, or environment. A stopped scheduler or worker may leave no new Python traceback to inspect.

PingCron watches for your next expected success check-in and alerts after the configured schedule and grace period. Investigate the job and its reporting path when a signal is missing; the absence alone does not identify the cause.

Setup

Add one success heartbeat to an existing Python job.

Example: an hourly sync_orders.py script. Adapt the workload, paths, and schedule to your application; keep your existing scheduler.

Create a monitor and store its private success URL as PINGCRON_URL in the scheduled process’s environment. Match the job’s schedule and timezone, with grace for normal runtime and delay. The example below sends success only; failed work is detected through the missing expected check-in.

Real-world examples

1. Install Requests in the same virtualenv as the job

/opt/app/.venv/bin/python -m pip install requests

2. Adapt jobs/sync_orders.py — preserve your real workload

import logging
import os
import requests


def report_success():
    url = os.environ.get("PINGCRON_URL", "").strip()
    if not url:
        logging.warning("Heartbeat not configured; check PINGCRON_URL")
        return
    try:
        with requests.get(
            url, timeout=(3, 10), allow_redirects=False, stream=True
        ) as response:
            if not 200 <= response.status_code < 300:
                raise requests.HTTPError("Heartbeat rejected")
    except requests.RequestException:
        # Do not log the exception or private URL.
        logging.warning("Work completed, but heartbeat delivery failed")


def main():
    # Replace with your real work. It must raise if required work fails.
    sync_orders()
    report_success()


if __name__ == "__main__":
    main()

3. User crontab: one physical line, using the actual virtualenv interpreter

0 * * * * cd /opt/app && /opt/app/.venv/bin/python /opt/app/jobs/sync_orders.py

Verify the scheduled environment and first receipt

Replace the placeholder sync_orders() with your work. It must raise on failure; if it returns a failure status, check that before report_success(). Wait for required uploads or worker processing to finish.

Add Requests to your project’s normal dependency management before deployment. The example uses a 3-second connection timeout and a 10-second read timeout, not a total request deadline or job-runtime limit. It accepts only 2xx responses, does not follow redirects, and closes the response without downloading its body.

  1. Use the deployed environment: verify the interpreter, installed dependencies, working directory, and file permissions under the scheduler’s account. Supply PINGCRON_URL through that process’s secret configuration or a protected environment file your launcher loads. An interactive shell export is not sufficient; keep the URL out of public code and logs.
  2. Match the expectation: this cron entry runs at the top of each hour in the scheduler’s timezone. Match that in PingCron, with grace for runtime and delay. Keep one scheduler entry per job.
  3. Confirm real work: inspect the workload’s output and its first successful heartbeat. A manual run tests reporting; also verify a later automatic scheduled run. A receipt alone does not prove the synced data is correct.
  4. Verify your alert destination: save email, Slack, or Discord settings, send the labeled test, and confirm receipt. Set up and verify an alert destination. Test missed-run detection separately with an isolated short-interval monitor; do not interrupt production work.

No receipt? Check process startup, workload errors, URL configuration, and outbound HTTPS. Review cron schedules and grace periods.

Beat reports a due task, but the worker produces no output? Diagnose a Celery Beat task that does not run with queue checks and a reproducible routing lab.

When more Python jobs justify Pro

Free includes 5 monitors, 7-day receipt history, and email, Slack, and Discord alerts. Pro is $9.99/month for up to 50 monitors, 30-day receipt history, and custom outbound webhooks for one account owner.

Choose Pro when you need more than five independently monitored jobs, longer retained history, or custom webhooks. Stay on Free if it fits. Shared account access starts on Team.

Choose Pro — $9.99/month

Create your account, then continue to checkout for the paid subscription.

References: Requests errors and redirects · Timeout semantics · Python virtual environments.

FAQ

Call report_success() after required work completes inside the worker task or scheduled function. Submitting a Celery task is not completing it. Preserve your existing exception and retry handling; do not send success from a finally block or immediately after queue dispatch. Use separate monitors for independently scheduled jobs.
The workload runs outside the reporting try block, so its exception is preserved and no success request is sent. After successful work, network or HTTP errors produce a generic warning without changing the workload result. A missing URL also produces a warning: monitoring is not installed until you verify a receipt.
No. The job may have failed, hung, never started, or completed without delivering its heartbeat. Inspect scheduler history, worker state, workload output, and reporting logs. PingCron does not restart scripts, inspect Python exceptions, or validate output correctness.
No, when you invoke that virtualenv’s Python executable by its absolute path. Install Requests and your workload dependencies into that environment and test with the scheduler’s account and working directory. An environment variable exported only in your interactive shell may not reach cron.

Related monitoring guides

Verify one Python job before adding the rest.

Confirm a scheduled heartbeat and your alert destination. Start with five free monitors, then choose a paid plan when its capacity or history meets a real need.

Monitor one Python script free

5 monitors free · No credit card · Verify a real scheduled run