Deployment

Cron jobs: run scripts and API calls on a schedule

Run a script, a command or a call to your own API on a schedule, in your time zone, with retries, a time limit and every run's exit code and output.

Updated

What you can run as a cron job

A cron job runs a task at set times and then stops: a script, a command, or a call to one of your own APIs. These are typical jobs:

JobWhenWhat runs
Charge subscription renewalsEvery night at 00:05One curl call to your private billing API. See the example.
Email the last day's sales to the team08:00 on weekdays, New York timeA Python script that reads PostgreSQL and sends one email. See the example.
Delete expired sessionsEvery hournode scripts/delete-expired-sessions.js
Pull new orders from StripeEvery 15 minutesA script that keeps the ID of the last order in its storage folder, so each run starts where the last one stopped.
Send monthly invoices06:00 on the 1st, London timebundle exec rake invoices:monthly
Rebuild the sitemapEvery day at 03:00npm run sitemap

ProductEcho starts each run at its time, in the time zone you choose, and records how it went. Between runs nothing is running, and a cron job has no web address of its own.

  • Reaches your other apps. A run can call the apps in your workspace at their internal addresses, private apps included. It can also reach your databases and any public API.
  • In your time zone. Set America/New_York, and a run at 08:00 stays at 08:00 New York time when the clocks change.
  • Every run on record. The job's Runs tab lists each run with its status, start time, duration and output. A retry shows as a second attempt under the same run.
  • From the console or your coding agent. Claude Code, Cursor and Codex can create a cron job, start a run and read its output over the Model Context Protocol (MCP).
Your code needs a Dockerfile

ProductEcho builds every cron job from a Dockerfile, so the GitHub repository or the ZIP you upload must contain one. It can sit beside your app's own Dockerfile under another name, such as Dockerfile.cron. When there are several, you pick the one the job uses.

Part of Pro

Cron jobs are part of the Pro plan, up to 50 per workspace. A run uses compute only while it runs, charged at the standard compute rate on the pricing page.

Example: call your own API every night

A billing API already has an endpoint that charges the subscriptions due today. It runs as a private app, so nothing outside the workspace can call it. The cron job only has to call that endpoint at 00:05 every night.

Add one file to the API's repository, next to its own Dockerfile:

Dockerfile.cron
FROM curlimages/curl:8.11.1

Then create the cron job with Dockerfile.cron as its Dockerfile and this command:

Command
curl -fsS -X POST -H "Authorization: Bearer $CRON_TOKEN" "$BILLING_API_URL/tasks/charge-renewals"
  • Variables: BILLING_API_URL is the billing API's internal address, such as http://ab12cd34-billing-api-svc. CRON_TOKEN is a secret the endpoint checks.
  • Schedule: 5 0 * * * in UTC, shown as Every day at 00:05.

When the API answers 200, curl prints the response, such as {"charged": 12}, and the run shows Succeeded. When the API answers with an error, -f makes curl exit with code 22. The run then shows Failed, and its output has the reason: curl: (22) The requested URL returned error: 500.

The token still matters on a private app, because every app in the workspace can reach the endpoint. Private API vs public API explains why. Your coding agent can set the whole job up, internal address included:

Any MCP client
Add a ProductEcho cron job named charge-renewals from my billing-api repository, using Dockerfile.cron. Every night at 00:05 UTC it should POST to /tasks/charge-renewals on the billing-api app, with the CRON_TOKEN from my .env file.

Example: a sales email every weekday at 08:00

A shop wants the last 24 hours of sales in the team's inbox at 08:00 New York time, Monday to Friday. The job is one Python script in its own repository. It reads the orders table in the shop's PostgreSQL database, sends one email and exits.

sales-report/
sales-report/
├── Dockerfile
├── requirements.txt
└── daily_sales.py
daily_sales.py
import os
import smtplib
from email.message import EmailMessage

import psycopg

with psycopg.connect(os.environ["DATABASE_URL"]) as conn:
    orders, revenue = conn.execute(
        "SELECT count(*), coalesce(sum(total), 0) FROM orders "
        "WHERE created_at > now() - interval '24 hours'"
    ).fetchone()

msg = EmailMessage()
msg["Subject"] = f"Sales, last 24 hours: {orders} orders, ${revenue:,.2f}"
msg["From"] = os.environ["REPORT_FROM"]
msg["To"] = os.environ["REPORT_TO"]
msg.set_content(f"{orders} orders, ${revenue:,.2f} in total.")

with smtplib.SMTP_SSL(os.environ["SMTP_HOST"], 465) as smtp:
    smtp.login(os.environ["SMTP_USER"], os.environ["SMTP_PASSWORD"])
    smtp.send_message(msg)

print(f"Sent: {orders} orders, ${revenue:,.2f}")
Dockerfile
FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY daily_sales.py .
CMD ["python", "daily_sales.py"]
requirements.txt
psycopg[binary]==3.3.9

The exit code decides the run's status. When the email is sent, the script prints one line and exits with 0, and the run shows Succeeded. If the mail server refuses the connection, Python exits with 1, the run shows Failed, and the traceback is in the run's output.

psycopg[binary] 3.3 bundles a PostgreSQL 18 client library, which supports the sslnegotiation=direct setting in your DATABASE_URL. PostgreSQL explains that setting.

Deploy it from your coding agent

Push the folder to GitHub, then ask your agent:

Any MCP client
Deploy github.com/acme/sales-report to ProductEcho as a cron job named sales-report. Run it at 08:00 Monday to Friday, New York time. Set DATABASE_URL from my shop-db database, and the REPORT_ and SMTP_ variables from my .env file.

The agent calls inspect_cron_job_source, which finds the Dockerfile and the command it runs, then deploy_cron_job:

MCP tool call
deploy_cron_job(
  name="sales-report",
  git_url="https://github.com/acme/sales-report",
  schedule="0 8 * * 1-5",
  time_zone="America/New_York",
  env_vars={"DATABASE_URL": "postgresql://…", "REPORT_TO": "team@acme.com", …}
)

ProductEcho builds the image and schedules the job. The job page shows the schedule in words, At 08:00 on Monday to Friday (America/New_York), and the time of the next run. Every weekday morning the Runs tab gets a new row. Open it to read what the script printed, such as Sent: 3 orders, $3,118.50. A push to the branch rebuilds the image, and the next run uses it.

Create a cron job

Your GitHub repository or ZIP must contain a Dockerfile, because ProductEcho builds the job from it. If it has several, you choose which one the job uses.

In the console

01

Start a new cron job

In the sidebar, choose Cron jobs, then New cron job. Give it a name of up to 40 characters: lowercase letters, digits and hyphens.
02

Source

Connect a GitHub repository and pick a branch, or upload a ZIP of the folder with its Dockerfile in it.
03

Build

ProductEcho lists the Dockerfiles it found. Pick one and check the folder it builds from.
04

Run

Leave Command empty to run the Dockerfile's own command, or type one line, such as python daily_sales.py. Set the size, variables, retries, a time limit and, if the job needs one, a storage folder.
05

Schedule

Choose On a schedule, then Every hour, Every day, Every week or Custom for your own cron expression, and set the time zone. Or choose Once, now to run the job once, straight after the deploy, with no schedule.
06

Deploy

The steps turn into a progress view: the build, the schedule and, for Once, now, the first run. See its runs then opens the job page.

Or ask your coding agent

Describe the job in plain language. Two more examples:

Any MCP client
Run scripts/delete-expired-sessions.js from my api repository every hour as a ProductEcho cron job.
Any MCP client
Run my sales-report cron job now and show me what it printed.

The tools your agent calls are listed under Tools your coding agent calls.

Schedules and time zones

A schedule is a cron expression with five fields: minute, hour, day of the month, month and day of the week. ProductEcho shows it in words, with the time of the next run, before you deploy.

ExpressionWhen it runs
*/15 * * * *Every 15 minutes
30 * * * *Every hour at minute 30
0 3 * * *Every day at 03:00
0 8 * * 1-5At 08:00 on Monday to Friday
@weeklyEvery Sunday at 00:00
@monthlyOn day 1 of every month at 00:00
  • @hourly, @daily and @yearly work too.
  • Runs are at least 5 minutes apart, so */5 * * * * is the most often a job can run. There is no seconds field.
  • The time zone is a name from the IANA list, such as America/New_York, Europe/London or Asia/Kolkata. Without one, the schedule runs in UTC.
  • When both the day of the month and the day of the week are set, the job runs when either one matches: 0 0 1 * 1 runs on the 1st and on every Monday.
Daylight saving

In a time zone that changes its clocks, a run set inside the hour that is skipped or repeated can move or be skipped that night. For a job that must run every night, pick a time outside that hour, or use UTC.

Runs, retries and overlaps

At each time on the schedule, ProductEcho starts a new container from the job's latest image, with its command, size and variables. Each run moves through these statuses:

StatusWhat it means
StartingThe container is being prepared. This can take a minute or two while a server is made ready for it.
RunningThe command is running. With retries, the row shows which attempt it is.
RetryingAn attempt failed, and the next attempt has not started yet.
SucceededThe command exited with code 0.
FailedEvery attempt failed. The reason is the last attempt's, such as Exit code 1 or Out of memory (512 MB).
Timed outThe run reached its time limit and was stopped.
StoppedSomeone pressed Stop run, or the job was deleted while it ran.
SkippedThe previous run was still going at this time, so this run did not start.

One run at a time

A job never runs twice at once. If a run is still going when the next one is due, the next one is skipped and listed as Skipped. If the earlier run ends within 5 minutes of that time, the next run starts late instead. Run now is refused while a run is going.

Retries

With retries set, a failed attempt is tried again in a new container, up to 5 times. The wait between attempts starts at 10 seconds and doubles each time. Each attempt is listed under its run with its own exit code and output.

A retry repeats the whole run

If the sales email went out and the script failed afterwards, a retry sends it again. Keep retries at 0, the default, unless the job is safe to run twice. Background jobs and cron shows how to make a job safe to repeat.

Read a run's output

Open a run on the Runs tab to read what it printed, for each attempt or for all of them. Output is kept for 7 days. Your agent reads the same output with get_cron_job_run_logs.

Settings you can change

Change any setting on the job's Settings tab, or ask your agent. A change to the source, the Dockerfile or the build folder rebuilds the image. Everything else applies to the next run.

SettingDefaultWhat you can set
CommandThe Dockerfile's CMD or ENTRYPOINTOne line of up to 1,000 characters, run with /bin/sh -c, so cd app && python main.py and $VARIABLES work.
SizeStarter: 0.25 vCPU, 512 MBMicro (0.125 vCPU, 256 MB), Starter, Medium (0.5 vCPU, 1 GB), Large (1 vCPU, 2 GB) or Performance (2 vCPU, 4 GB).
VariablesNonePlain values, as on an app. Build values, such as names that start with VITE_ or NEXT_PUBLIC_, rebuild the image when they change.
Retries00 to 5.
Time limit1 hour1 minute to 12 hours. A run that passes it is stopped and shows Timed out.
StorageNoneA folder, such as /data, whose files are kept from run to run.
ScheduleNoneA cron expression and a time zone, or Only when started.
Rebuild on every pushOn for GitHubOff: the image is rebuilt only when you ask.
Store run logsOnOff: run output is no longer kept.

A typed command replaces the image's own ENTRYPOINT and CMD. An image without a shell, such as a scratch or distroless image, cannot run a typed command. For those, leave Command empty and set CMD in the Dockerfile.

Keep files between runs

Each run starts with a clean disk. To carry something from one run to the next, such as the ID of the last order a sync fetched, add a storage folder. It works like an app's persistent storage: the files stay until the job deletes them or you remove the folder. The folder has no backups and is not for databases.

Run now, pause, stop and delete

  • Run now starts a run at once, including on a paused job. Use it to try a change without waiting for the schedule.
  • Pause schedule stops new scheduled runs, and a run in progress finishes. Resume schedule turns the schedule back on.
  • Stop run ends the run in progress. Your process gets a stop signal (SIGTERM) and 30 seconds to exit, and the run shows Stopped.
  • Only when started, under Schedule on the Settings tab, removes the schedule. The job then runs only when you press Run now or ask your agent.
  • Delete stops a run in progress and removes the job's schedule, image and stored files. Stored files cannot be recovered.

Tools your coding agent calls

A connected agent manages cron jobs with these MCP tools. If yours is not connected yet, see Connect your coding agent.

ToolWhat it does
inspect_cron_job_sourceLists the Dockerfiles in a GitHub branch or an uploaded ZIP, with the command each one runs.
preview_cron_scheduleShows a schedule in words and its next 5 run times.
deploy_cron_jobCreates a cron job, or changes one. Only the settings it passes change.
list_cron_jobs, get_cron_jobLists your cron jobs, or shows one with its status, next run and last run.
run_cron_jobStarts a run now.
get_cron_job_runsShows the run history, or one run with its attempts.
get_cron_job_run_logsReturns what a run printed.
stop_cron_job_runStops the run in progress.
pause_cron_job, resume_cron_jobTurns the schedule off and back on.
delete_cron_jobDeletes the job, after you confirm its name.

Good to know

  • Start time. A run can start a minute or two after its time, while a server is made ready for it. Its time limit counts that wait.
  • Limits on Pro. Up to 50 cron jobs per workspace, runs at most every 5 minutes, sizes up to 2 vCPU and 4 GB, and up to 12 hours per run. Contact us if you need more jobs.

Questions

Do I need a Dockerfile to run a cron job?+

Yes. The GitHub repository or ZIP you deploy must contain a Dockerfile, and ProductEcho builds the job from it. One line is enough to call an API, and six are enough for a Python script, as in the examples above.

Can a cron job call my other apps and APIs?+

Yes. A run can call any app in its workspace at the app's internal address, private apps included, and any public API. Save the address on the job as a variable, such as API_URL.

What happens if a run is still going when the next one is due?+

The next run is skipped and listed as Skipped, so two runs of a job never overlap. If the earlier run ends within 5 minutes, the next run starts late instead.

Can a cron job use my PostgreSQL database?+

Yes. Set DATABASE_URL as a variable on the job, or ask your agent to copy it from the database. The job connects over TLS, the same way an app does.

Can a cron job run every minute?+

No. Runs are at least 5 minutes apart. For work that must happen every minute, keep a worker running in a full-stack app.

Does a push to GitHub update the job?+

Yes, when Rebuild on every push is on, as it is by default for GitHub. The next run uses the new image, and a run already going finishes on the old one.

What does a cron job cost?+

Cron jobs are part of Pro, up to 50 per workspace. A run uses compute only while it runs, charged at the standard compute rate shown on the Pricing page.

Read PostgreSQL databases