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.
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:
| Job | When | What runs |
|---|---|---|
| Charge subscription renewals | Every night at 00:05 | One curl call to your private billing API. See the example. |
| Email the last day's sales to the team | 08:00 on weekdays, New York time | A Python script that reads PostgreSQL and sends one email. See the example. |
| Delete expired sessions | Every hour | node scripts/delete-expired-sessions.js |
| Pull new orders from Stripe | Every 15 minutes | A script that keeps the ID of the last order in its storage folder, so each run starts where the last one stopped. |
| Send monthly invoices | 06:00 on the 1st, London time | bundle exec rake invoices:monthly |
| Rebuild the sitemap | Every day at 03:00 | npm 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).
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.
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:
Then create the cron job with Dockerfile.cron as its Dockerfile and this command:
- Variables:
BILLING_API_URLis the billing API's internal address, such ashttp://ab12cd34-billing-api-svc.CRON_TOKENis 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:
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.
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:
The agent calls inspect_cron_job_source, which finds the Dockerfile and the command it runs, then deploy_cron_job:
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
Start a new cron job
Source
Build
Run
python daily_sales.py. Set the size, variables, retries, a time limit and, if the job needs one, a storage folder.Schedule
Deploy
Or ask your coding agent
Describe the job in plain language. Two more examples:
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.
| Expression | When it runs |
|---|---|
*/15 * * * * | Every 15 minutes |
30 * * * * | Every hour at minute 30 |
0 3 * * * | Every day at 03:00 |
0 8 * * 1-5 | At 08:00 on Monday to Friday |
@weekly | Every Sunday at 00:00 |
@monthly | On day 1 of every month at 00:00 |
@hourly,@dailyand@yearlywork 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/LondonorAsia/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 * 1runs on the 1st and on every Monday.
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:
| Status | What it means |
|---|---|
| Starting | The container is being prepared. This can take a minute or two while a server is made ready for it. |
| Running | The command is running. With retries, the row shows which attempt it is. |
| Retrying | An attempt failed, and the next attempt has not started yet. |
| Succeeded | The command exited with code 0. |
| Failed | Every attempt failed. The reason is the last attempt's, such as Exit code 1 or Out of memory (512 MB). |
| Timed out | The run reached its time limit and was stopped. |
| Stopped | Someone pressed Stop run, or the job was deleted while it ran. |
| Skipped | The 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.
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.
| Setting | Default | What you can set |
|---|---|---|
| Command | The Dockerfile's CMD or ENTRYPOINT | One line of up to 1,000 characters, run with /bin/sh -c, so cd app && python main.py and $VARIABLES work. |
| Size | Starter: 0.25 vCPU, 512 MB | Micro (0.125 vCPU, 256 MB), Starter, Medium (0.5 vCPU, 1 GB), Large (1 vCPU, 2 GB) or Performance (2 vCPU, 4 GB). |
| Variables | None | Plain values, as on an app. Build values, such as names that start with VITE_ or NEXT_PUBLIC_, rebuild the image when they change. |
| Retries | 0 | 0 to 5. |
| Time limit | 1 hour | 1 minute to 12 hours. A run that passes it is stopped and shows Timed out. |
| Storage | None | A folder, such as /data, whose files are kept from run to run. |
| Schedule | None | A cron expression and a time zone, or Only when started. |
| Rebuild on every push | On for GitHub | Off: the image is rebuilt only when you ask. |
| Store run logs | On | Off: 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.
| Tool | What it does |
|---|---|
inspect_cron_job_source | Lists the Dockerfiles in a GitHub branch or an uploaded ZIP, with the command each one runs. |
preview_cron_schedule | Shows a schedule in words and its next 5 run times. |
deploy_cron_job | Creates a cron job, or changes one. Only the settings it passes change. |
list_cron_jobs, get_cron_job | Lists your cron jobs, or shows one with its status, next run and last run. |
run_cron_job | Starts a run now. |
get_cron_job_runs | Shows the run history, or one run with its attempts. |
get_cron_job_run_logs | Returns what a run printed. |
stop_cron_job_run | Stops the run in progress. |
pause_cron_job, resume_cron_job | Turns the schedule off and back on. |
delete_cron_job | Deletes 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.