Articles

How to run a Python script on a schedule without a server: GitHub Actions vs Render vs Railway vs Heroku Scheduler

Intervals, timezones, missed runs and time limits for scheduled jobs on GitHub Actions, Render, Railway, Heroku Scheduler and Gregale crons.

Updated

To run a Python script on a schedule without a server, you need a host that starts your code at the scheduled minute and stops paying for it afterwards. GitHub Actions, Render, Railway and Heroku start a fresh process or container for every run. Gregale calls an HTTP route on your app instead, waking it from a snapshot. Our test job, on an app parked to disk, finished 617 ms after the run started. The differences that matter are the shortest interval, whether a run can be skipped or doubled, and the time limit.

Gregale publishes this page. Every limit names its vendor and comes from that vendor's own docs, checked on November 30, 2026. The Gregale numbers are from our own test, described below.

At a glance

HostShortest intervalTimezoneWhen a run goes wrongTime limit
GitHub Actions (schedule)Every 5 minutesUTC by default, or an IANA zoneDelayed under load; some queued runs may be droppedThe job's own timeout
Render Cron JobsNot stated; examples run every 10 minutesUTCThe next run waits until the active one finishes12 hours
Railway cron5 minutes apartUTCA run is skipped while the previous one is still active; start times can drift by a few minutesThe service must exit
Heroku SchedulerEvery 10 minutesUTCRarely missed, and very rarely run twiceAbout one interval
Gregale cronsEvery minuteAny IANA zone, daylight saving handledDelivered at most once; skip_if_running skips while a run is active30 seconds by default

GitHub Actions

A workflow with an on: schedule cron runs a job on GitHub's runners. The shortest interval is every 5 minutes, and schedules run only on the default branch. GitHub says scheduled runs can be delayed when Actions is busy, and if the load is high enough, some queued jobs may be dropped. In a public repository, scheduled workflows are disabled after 60 days without repository activity.

It works well for jobs that only need the repository and a few secrets. A job that writes to your database has to reach it from GitHub's network.

Render

A Render Cron Job is its own service that runs a command on a schedule, in UTC. It is billed per second of running time, with a minimum of $1 a month per cron job. A run is stopped after 12 hours. If a run is still going at the next scheduled time, Render delays the next run until it finishes.

Railway

Any Railway service can run on a cron schedule instead of staying up. Runs must be at least 5 minutes apart, in UTC, and Railway says start times can vary by a few minutes. The command has to finish and exit, closing its database connections: while a previous run is still active, the next one is skipped.

Heroku Scheduler

Heroku Scheduler is a free add-on that runs a command in a one-off dyno every 10 minutes, every hour or every day, with daily times in UTC. The dynos count toward your dyno usage. Heroku says execution is expected but not guaranteed: it occasionally misses a job and, in very rare cases, runs one twice. A run is stopped after about its interval, and Heroku suggests a worker dyno for anything that takes more than a couple of minutes.

Gregale

A Gregale cron sends an HTTP POST to a path on your app. If the app is parked, the request wakes it, restored from a snapshot, exactly as a visitor's request would. Once it answers, the app goes idle again.

  • Schedules take standard five-field cron expressions, down to one minute, in any IANA timezone, with daylight saving handled.
  • Delivery is at most once. A failed run isn't retried; the next scheduled time is the next attempt. If Gregale can't hand the request to the app at all, it tries again after 5 and 10 seconds.
  • Only your cron can send X-Faas-Invocation-Source: cron: Gregale strips X-Faas-* headers from visitors' requests. Each run also carries an X-Faas-Invocation-Id.
  • The handler has 30 seconds, or the app's request timeout when it is longer and the plan allows it. Longer work belongs in a job.
  • Crons need Hobby or above: 5 per app and 10 per account on Hobby, which is $10 a month.

Crons can live in gregale.yaml, next to the code. A deploy then creates, changes or removes them to match the file:

yaml
triggers:
  - kind: cron
    app: python-cron-postgres
    schedule: '5 * * * *' # five past every hour
    path: /cron/rollup
    skip_if_running: true
  - kind: cron
    app: python-cron-postgres
    schedule: '30 3 * * *' # 03:30 every day, Istanbul time
    path: /cron/prune
    timezone: Europe/Istanbul

Make the job safe to run twice, or not at all

Every host above can, in some case, run a job late, twice, or not at all. Write the job so that doesn't matter:

  1. Check who's calling. On Gregale, refuse the job route unless the request carries X-Faas-Invocation-Source: cron.
  2. Record each run before doing the work. Insert the invocation id into a table with a primary key, and skip the run if the insert finds it already there.
  3. Recompute rather than increment. A rollup that recounts the last 48 hours from raw rows ends with the right numbers even after a missed run.
  4. Bound the work. Delete old rows in batches, so a run stays well inside its time limit.

In FastAPI, that is one route:

python
@app.post("/cron/{job}")
def run_job(job: str,
            x_faas_invocation_source: str | None = Header(default=None),
            x_faas_invocation_id: str | None = Header(default=None)):
    if x_faas_invocation_source != "cron":
        raise HTTPException(403, "cron routes answer only Gregale crons")
    with db.pool().connection() as conn:
        conn.autocommit = True
        if not jobs.claim_run(conn, x_faas_invocation_id, job):
            return {"skipped": "already ran"}
        with conn.transaction():
            detail = jobs.JOBS[job](conn)
        jobs.finish_run(conn, x_faas_invocation_id, "done", detail)
    return detail

The complete app, with tests, is gregale-dev/python-cron-postgres. One command deploys the app, its PostgreSQL database and both crons:

bash
git clone https://github.com/gregale-dev/python-cron-postgres
cd python-cron-postgres
gregale deploy --name python-cron-postgres

What we measured

We deployed that repository on Gregale on 2026-11-30, at 512 MB:

  • Deploy: 176 seconds from gregale deploy to a live release with both crons active, including creating the database.
  • A cron run against a parked app: 617 ms from start to finish, as gregale cron runs reports it, including the wake.
  • The wake: the app was restored from its snapshot in 77 ms.
  • A visitor sending the cron header: 403, because Gregale removed the header before the request reached the app.

Which one to pick

  • A job that only touches the repository, such as regenerating a file or opening an issue: GitHub Actions.
  • A long batch job, up to hours: Render Cron Jobs or a Railway cron service, both in UTC.
  • An app already on Heroku with jobs that tolerate a rare miss: Heroku Scheduler.
  • A short job that belongs to a web app and its database, on a schedule down to the minute in your own timezone: a Gregale cron calling the app.

For Cloudflare Workers and Vercel schedules, what happens when runs overlap, and what a small job costs on each host, see Cron job hosting compared.

Sources

Checked on November 30, 2026: GitHub Actions schedule event, Render Cron Jobs, Railway cron jobs, Heroku Scheduler, Gregale crons and Gregale plans.

Questions

How do I run a Python script every hour without keeping a server running?

Use a scheduler that starts your code at the scheduled minute: a GitHub Actions schedule, a Render Cron Job, a Railway cron service or Heroku Scheduler starts a process for each run, and a Gregale cron sends an HTTP POST to your app, waking it from a snapshot. In our test, a Gregale cron run against a parked app finished 617 ms after it started.

What is the shortest interval for a scheduled job?

Every 5 minutes on GitHub Actions and Railway, every 10 minutes on Heroku Scheduler, and every minute on Gregale crons. Render does not state a minimum; its examples run every 10 minutes.

Can a scheduled job run twice or be skipped?

Yes, on every host in some case. GitHub may drop queued scheduled runs under high load, Railway skips a run while the previous one is still active, and Heroku Scheduler occasionally misses a job and very rarely runs one twice. Record each run id in a table before doing the work, and recompute results instead of incrementing them, so a doubled or missed run does no harm.

Can a cron job run in my own timezone?

GitHub Actions and Gregale take an IANA timezone, and Gregale follows daylight-saving rules for it. Render, Railway and Heroku Scheduler schedule in UTC, so you add the offset yourself.