EthioDeploy
DocsPricingDomainsBlogToolsChangelog

Blog/Tutorials

Cron jobs on a PaaS: how to run scheduled tasks

BS
Brook SolomonPublished November 29, 2026
Share on XShare on LinkedIn
*/15 * * * *

THE SHORT ANSWER

A PaaS without a cron service runs scheduled jobs in one of two ways: a scheduler inside a process that never stops, or an outside scheduler that calls a protected URL in your app. EthioDeploy has no cron service type, so you run APScheduler, node-cron, Celery beat, Laravel's schedule:work or Solid Queue in a Background Worker, or call an endpoint from a scheduled GitHub Actions workflow. A scheduler inside a Free web app misses its jobs while the app sleeps, which happens after 30 minutes without traffic. Background Workers don't sleep, and on Pro and Business nothing sleeps.

Why a crontab doesn't work on a PaaS

On a server you own, the cron daemon reads your crontab and starts each command on time. A PaaS runs your app in a container that starts one process, your start command, and nothing else. No cron daemon runs in it, and every deploy replaces the container, so a crontab line has nothing to read it.

Some platforms add a cron service type that starts a container on a schedule. Without one, you have two options:

  1. Run a scheduler inside a process that stays up: a library that keeps the schedule in memory and calls your function when it's due.
  2. Let something outside call your app on a schedule. A scheduled GitHub Actions workflow sends an HTTP request to a protected route, and the route does the job.

EthioDeploy has no cron service type. Every project or service is either a Web Service or a Background Worker, so scheduled jobs use one of the two options above.

Which process keeps a schedule firing?

An in-process scheduler only runs while its process runs. On EthioDeploy that depends on the plan and on the kind of process:

Where the scheduler runsDoes it fire on time?
Free web serviceOnly while the app is awake. It sleeps after 30 minutes without traffic, and jobs due while it sleeps are skipped.
Free Background WorkerYes. Workers don't sleep. Memory and CPU count against the Free plan's monthly quota of 50 GB-hours and 20 CPU-hours. Free has one project, so this project has no web service.
Pro or Business web serviceYes, it never sleeps. It can run twice, though: see the next paragraph.
Pro or Business worker serviceYes. This is the setup we recommend: a separate service from the same repo that runs only the scheduler.

Putting the scheduler in the web process has two problems even when the app never sleeps. Servers like gunicorn and PM2 cluster mode start several copies of your app, and each copy starts its own scheduler. And a web deploy starts the new container while the old one still serves traffic, so for a short time two schedulers run. A Background Worker deploy stops the old process before it starts the new one, so only one copy runs at a time.

On Pro and Business, add the scheduler as a service: open the project's Services tab, click Add service, pick Background worker and set its start command. It runs from the same repo with the same env vars and databases. From the CLI:

ethiodeploy services add scheduler --start "python scheduler.py"

Services have no pull request previews, so a preview deploy never runs your jobs a second time against the production database.

Python: APScheduler or Celery beat

For a few jobs and no task queue, APScheduler in its own script is the simplest choice. Pin version 3: the 4.x releases are still pre-releases with a different API. BlockingScheduler is the one to use when the scheduler is the only thing the process does:

# requirements.txt: APScheduler>=3.11,<4
import logging

from apscheduler.schedulers.blocking import BlockingScheduler
from apscheduler.triggers.cron import CronTrigger

logging.basicConfig(level=logging.INFO)
sched = BlockingScheduler(timezone="UTC")


@sched.scheduled_job(CronTrigger.from_crontab("*/15 * * * *", timezone="UTC"))
def clean_expired_sessions():
    ...  # your job


sched.start()

Deploy it as a Background Worker with the start command python scheduler.py. In a Django project, call django.setup() at the top of the script (after setting DJANGO_SETTINGS_MODULE) before importing models, or write the job as a management command.

APScheduler's FAQ warns against starting it inside a web app that runs several worker processes: each process gets its own scheduler and the jobs run more than once. Its own advice is to run the scheduler in a dedicated process.

If the app already uses Celery, use Celery beat. Beat only sends tasks to the queue and a Celery worker runs them, so you need both processes and a broker. Celery's docs say to run only one beat at a time, or tasks are sent twice. The Django + Celery + Redis guide covers the worker, beat and Redis setup on EthioDeploy.

Node.js: node-cron

node-cron takes a crontab expression, with an optional sixth field for seconds. Version 4 starts a task as soon as you schedule it. noOverlap skips a run while the previous one is still going:

// scheduler.js  (npm install node-cron)
import cron from "node-cron";
import { cleanExpiredSessions } from "./jobs.js";

cron.schedule(
  "*/15 * * * *",
  async () => {
    await cleanExpiredSessions();
  },
  { timezone: "UTC", noOverlap: true },
);

Run it as a Background Worker with node scheduler.js. The timer keeps the process alive, so the file needs nothing else. NestJS apps that use @nestjs/schedule have the same sleep and duplicate problems as any scheduler in a web process: on Free, the @Cron() jobs stop while the app sleeps.

Laravel and Rails

Laravel defines the schedule in routes/console.php. Laravel's docs run it with a cron entry that calls schedule:run every minute. Without cron, php artisan schedule:work does the same job: it stays in the foreground and runs the scheduler every minute. Use it as the start command of a worker service:

ethiodeploy services add scheduler --start "php artisan schedule:work"

Add ->withoutOverlapping() to jobs that can run longer than their interval. ->onOneServer() only matters when more than one scheduler runs, and it needs a cache all of them share, such as Redis. More on queues and the scheduler in the Laravel guide.

Rails 8 apps with Solid Queue list recurring jobs in config/recurring.yml. The scheduler runs inside bin/jobs, so a worker service with the start command bin/jobs runs both your queued jobs and the recurring ones. See the Rails guide.

An outside trigger: GitHub Actions calling a protected URL

This keeps the job code in your web app and moves only the clock outside. It is also the one way to run a job on time from a Free web app, because the request wakes the app. Add a route that does the job and only accepts a secret:

import { timingSafeEqual } from "node:crypto";

// Express. CRON_SECRET is an env var on the app and a secret in GitHub.
app.post("/internal/cron/cleanup", async (req, res) => {
  const expected = Buffer.from(`Bearer ${process.env.CRON_SECRET}`);
  const got = Buffer.from(req.get("authorization") ?? "");
  if (got.length !== expected.length || !timingSafeEqual(got, expected)) {
    return res.sendStatus(401);
  }
  await cleanExpiredSessions();
  res.sendStatus(204);
});

Then call it from .github/workflows/cleanup.yml:

name: cleanup
on:
  schedule:
    - cron: "0 3 * * *"
  workflow_dispatch:

jobs:
  call:
    runs-on: ubuntu-latest
    steps:
      - name: Call the cleanup route
        env:
          CRON_SECRET: ${{ secrets.CRON_SECRET }}
        run: |
          curl -fsS --max-time 120 --retry 2 -X POST \
            -H "Authorization: Bearer $CRON_SECRET" \
            https://<project-slug>.ethiodeploy.app/internal/cron/cleanup

The long --max-time is for a Free app that is asleep: the request waits up to 30 seconds while the app boots, then for the job itself. workflow_dispatch adds a button to run it by hand.

What GitHub's docs say about scheduled workflows:

  • The shortest interval is once every 5 minutes.
  • Runs can be delayed when GitHub Actions is busy, and under enough load some are dropped. Don't use it for jobs that must run at an exact minute.
  • Times are UTC unless you add a timezone key with an IANA name next to cron.
  • It runs the workflow file on the latest commit of the default branch.
  • In a public repo, scheduled workflows are turned off after 60 days without repository activity.
  • Standard runners are free in public repos. In a private repo, each run uses your account's Actions allowance, which adds up for a job every few minutes.

Make jobs safe to run twice, or to miss

Whatever runs the clock, a job will sometimes run twice or not at all: a deploy at the wrong second, a crash, a delayed GitHub run. Write jobs so that either is harmless:

  • Work from the database, not from the clock. “Send reminders that are due and not yet sent” catches up after a missed run; “send reminders for 9:00” doesn't.
  • Mark work done in the same transaction that does it, so a second run finds nothing left.
  • When two copies might start together, take a lock first. In Postgres, SELECT pg_try_advisory_lock(42) returns false for everyone but the first caller.
  • Keep long jobs short or resumable. A deploy stops the old container with SIGTERM and kills it 10 seconds later if it hasn't exited.

Questions

There is no cron service type. Run a scheduler such as APScheduler, node-cron, Celery beat, Laravel's schedule:work or Solid Queue inside a Background Worker, or have a scheduled GitHub Actions workflow call a protected route in your app.

Yes, two ways. Make the project a Background Worker that runs a scheduler: workers don't sleep, and they count against the Free plan's 50 GB-hours a month. Or keep a web app and call a protected route from a GitHub Actions schedule; the request wakes the app if it's asleep. A scheduler inside a Free web app skips jobs while the app sleeps.

On a PaaS the usual causes are: the process running the scheduler was asleep or restarting at that moment, the job ran in a different timezone than you expected (most schedulers and GitHub Actions default to UTC), or a scheduled GitHub workflow was delayed, dropped, or disabled after 60 days without activity in a public repo.

More than one scheduler is running. Common causes: the scheduler starts inside each gunicorn or PM2 worker process, two Celery beat processes run at once, or a web deploy briefly runs the old and new containers together. Run the scheduler in one dedicated worker process and take a lock in the job.

You can install cron in the image, but the container only runs your start command, so cron has to be that command or be started by it. Then the container is a scheduler, not a web app. A scheduler library in a Background Worker does the same with less setup.

Sources

Checked on November 29, 2026:

  • APScheduler 3.x: User guide
  • APScheduler 3.x: FAQ
  • APScheduler: cron trigger
  • node-cron on GitHub
  • node-cron: scheduling options
  • Celery: Periodic tasks
  • Laravel: Task scheduling
  • Solid Queue README
  • GitHub Docs: Events that trigger workflows (schedule)
  • GitHub Docs: GitHub Actions billing

Push a repo. Get a URL.

  • Web services and background workers
  • Deploy Django with Celery and Redis
  • Deploy a Laravel app
  • Pricing and plan limits
Start free

Join the EthioDeploy Telegram

Release notes as they ship, plus deploy help from the team and other developers.

Join on Telegram
BS
WRITTEN BYBrook SolomonFounder, EthioDeploy

Brook Solomon founded EthioDeploy and builds its deploy pipeline, build servers and AI coding agent. The posts here come from errors seen in real deploys on the platform.

All posts by Brook →
On this page
  • Why a crontab doesn't work on a PaaS
  • Which process keeps a schedule firing?
  • Python: APScheduler or Celery beat
  • Node.js: node-cron
  • Laravel and Rails
  • An outside trigger: GitHub Actions calling a protected URL
  • Make jobs safe to run twice, or to miss
  • Questions
  • Sources
0% read

Keep reading

  • Http::withToken(...)->post(...)

    TutorialsNov 15, 2026

    Accept Chapa payments in Laravel

    To take Chapa payments in Laravel, save a pending order with a unique tx_ref, POST it to https://api.chapa.co/v1/transaction/initialize with Laravel's HTTP client and your secret key, and redirect the customer to the checkout_url Chapa returns. Mark the order paid only after GET /v1/transaction/verify/<tx_ref> reports success with the amount, currency and mode you expect. Run that check from all three places Chapa can reach you: the GET to your callback_url, the customer's redirect to your return_url, and the webhook POST, which you exclude from Laravel's CSRF middleware.

  • POST /v1/transaction/initialize

    TutorialsNov 4, 2026

    Accept Chapa payments in Next.js and deploy it

    To take Chapa payments in Next.js, call Chapa's initialize endpoint from the server with your secret key, redirect the customer to the checkout_url it returns, and mark the order paid only after GET /v1/transaction/verify/<tx_ref> says the status is success and the amount, currency and mode match. Chapa tells you a payment happened three ways: the customer comes back to your return_url, Chapa calls your callback_url, and it POSTs a webhook. Treat all three as a cue to verify, never as proof.

  • Mixed Content: blocked

    Fix deploy errorsNov 29, 2026

    Mixed content blocked after moving to HTTPS: causes and fixes

    A mixed content error means the page loaded over HTTPS but asked for something over plain http://. Browsers block scripts, stylesheets, fetch() and XMLHttpRequest calls (Chrome: "This request has been blocked; the content must be served over HTTPS") and upgrade images, audio and video to https on their own. After a deploy the cause is usually one of three things: an http:// URL in your code or in an env var such as the API base URL, a backend behind a TLS-terminating proxy that thinks it runs on http and builds http:// links, or old http:// URLs saved in the database. Change the URLs to https:// or relative paths, make the framework trust X-Forwarded-Proto, and treat the upgrade-insecure-requests CSP directive as a stopgap.

EthioDeploy

Agentic first development and deployment, started in Ethiopia, built for developers everywhere.

Telegram community
Product
PricingAI coding agentAgent mode docsDomainsCLIFree backend hostingHosting in EthiopiaChangelog
Deploy guides
Next.jsNode.jsPythonSvelteKitTanStack StartAstroNuxtReact RouterHonoStrapiPayload CMSDjangoDjango + CeleryFastAPIFlaskStreamlitExpressNestJSSocket.IOLaravelRailsGoSpring BootASP.NET CoreTelegram botDiscord botWhatsApp botn8nLovableBoltReplitv0Google AI StudioBase44Firebase StudioClaude Code & Cursor
Compare
vs Herokuvs Vercelvs Rendervs Railwayvs Fly.iovs Netlifyvs KoyebHeroku alternativesVercel alternativesNetlify alternativesRender alternativesRailway alternativesFly.io alternativesReplit alternativesPythonAnywhere alternativesDigitalOcean App Platform alternativesGlitch alternatives
Resources
DocsBlogFree toolsAboutSupportContactllms.txt
© 2026 EthioDeployPay by card in USD or bank transfer in ETBTermsPrivacy