Open Cron Jobs
Open your website, click its name at the top of the page, then Hosting. Click Cron Jobs.
Cron Jobs on a Next.js site
- Run cron jobs switches every job on the site on or off. When it’s off, no job runs, but you can still add, change and remove jobs.
- Where jobs run chooses which of your site’s environments run them: all of them, Production only (your live site), or only Staging or Development.
- All times are in UTC.
On a Next.js site: use a scheduled workflow
On a Next.js site, Add Cron Job is turned off.
Add Cron Job, turned off
1
Put the job in a route of your site
Ask the builder AI to add a route that does the job, for example at
app/api/jobs/daily/route.ts, and that only acts when the request carries a secret you choose. Keep the secret in your site’s settings, not in the code: see Store a Secret Key for Your Site.2
Call it from a scheduled workflow
Make a workflow with a Scheduled Trigger and an API Call step that calls your route with the secret. See Run a Workflow on a Schedule.
On a site without a Next.js server
On a site that doesn’t run a Next.js server, click Add Cron Job. The Add a cron job box asks for:- Function to run: the function’s file in your site’s code, such as
functions/daily-tasks.ts. - Schedule: pick one from the list, or Custom schedule… to type a cron expression such as
0 2 * * *or a rate such asrate(6 hours). Times are in UTC. - Description: optional, for example “Daily cleanup of expired sessions”.
- Environment: where this job runs.
Good to know
- Use your local time carefully. Schedules are in UTC, so 9 AM in Portland is 16:00 or 17:00 UTC depending on daylight saving time. A workflow’s Scheduled Trigger lets you pick your own time zone.