BlogCron jobs

How to run a scheduled job on your app.

A scheduled job is a route that Antideploy calls on a schedule. It wakes your app if it is asleep, so no worker has to stay alive.

How the Agent API works
  • Standard cron, in UTCFive fields, or @daily and friends
  • A plain HTTP callA GET or POST to a path on your app
  • Wakes a sleeping appSo nothing has to stay running
  • On every planThree jobs per app, Free included

The short answer

To run a scheduled job, write a route in your app that does the work, then ask your connected coding agent to schedule it. Antideploy sends a request to that path on your schedule. It wakes the app if it is asleep, runs the route, and lets the app go back to sleep. You do not need a background worker, and a timer inside your server will not work, because an idle app sleeps.

Say this to your coding agent

Run /api/cron/nightly every day at 3am UTC.

If your agent is not connected yet, paste this first: Set this project up to deploy on Antideploy. Fetch https://antideploy.com/agent.md and follow it.

What your agent does

  1. It writes the route

    A nightly task is a route. For example, a route that deletes expired sessions.

  2. It creates the job

    A job is a path, a method and a schedule. The method is POST unless you say GET. Five-field cron in UTC, or @hourly, @daily, @weekly and @monthly.

  3. It reads the result

    Each job shows its next run and its last, the status of the last run and any error. The console has a Schedules panel for the same thing.

What the route looks like

Every run carries the header x-antideploy-cron: 1. Anyone can send a header, so a route that does real work should also check a secret that only your app knows.

Express
app.post("/api/cron/nightly", async (req, res) => {
  // anyone can send the cron header, so check a secret of your own for real work
  await deleteExpiredSessions();
  res.sendStatus(200);
});

The rules

  • Three jobs per app, on every plan
  • Runs are at least five minutes apart
  • A run is given up after 60 seconds, so keep each one short
  • Schedules are in UTC, so convert from your own time zone
  • Ten failures in a row pause the job, and resuming it resets the count
  • To change a schedule or a path, remove the job and add it again

Why not a timer in your server

A library such as node-cron, or a setInterval, needs the process to be running. Antideploy scales an idle app to zero, so the timer stops with it and never fires. Antideploy flags this before you deploy. Move the work into a route and schedule that route instead.

01Before you commit

Here's where it stops.

A platform that only tells you what it is good at is one you find the edges of in production. These are the ones to know before your first deploy.

  1. No background workers

    Only the web process runs. A queue consumer or a loop inside the app will not stay alive. Use a cron job to call a path on a schedule, or a webhook.

  2. Apps sleep when idle

    On every plan, an app nobody is using goes to sleep and the next visit wakes it. The first request took 2.9 to 13.9 seconds in our measurements, depending on the stack. There are no always-on workers, so use a cron job or a webhook for background work.

02Questions

Scheduled job questions, answered.

Anything else? Write to us and a person answers.

support@antideploy.com
What time zone are schedules in?

UTC. Write the schedule in UTC and convert from your own time zone. For example, 3am in India is 21:30 UTC the day before.

How often can a job run?

At most every five minutes.

Does a job wake a sleeping app?

Yes. A run is a request to your app's public address, so the app wakes to serve it. The first request after a quiet spell can take several seconds, well inside the 60 seconds a run is allowed.

What if my route takes longer than a minute?

The run is given up after 60 seconds. Keep each run short, and do the slow part in smaller steps over several runs.

How do I stop strangers calling my route?

Check a secret of your own in the route. Anyone can send the cron header.

Can I run a background worker instead?

Not today. Only the web process runs, and apps sleep when idle. Use a scheduled job, or a webhook.

Deploy something. Start with one sentence.

Paste one sentence into your coding agent, click Approve once, and get a live link. No card, no trial clock.

Start from GitHub or a folder
Prompt copied Paste it into Claude Code, Codex or Cursor and press Enter.