Skip to main content
A cron job runs a function in your site’s code on a schedule, such as a nightly cleanup or an hourly sync. Each site has a Cron Jobs page that lists its jobs and says where they run. Most Hiveku sites run as a Next.js app, and cron jobs only run on sites without a Next.js server. On those sites, the page says so and points you to a scheduled workflow instead. This guide opens the page on Northwind’s Pearl District site, which is a Next.js app.

Open Cron Jobs

Open your website, click its name at the top of the page, then Hosting. Click Cron Jobs.
Cron Jobs: Run a function in your site's code on a schedule; the note Cron jobs can't run on this site, outlined: Your site runs as a Next.js app, and cron jobs only run functions on sites without a Next.js server, with Run a workflow on a schedule; then Run cron jobs, Off; and Where jobs run, with All environments, Production only (chosen), Staging and Development, Staging only and Development only

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.
All times are in UTC; No cron jobs yet: A cron job runs a function in your site's code on a schedule. Functions your code gives a schedule are also added here when you deploy; and the Add Cron Job button greyed out, outlined

Add Cron Job, turned off

To run something on a schedule instead:
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 as rate(6 hours). Times are in UTC.
  • Description: optional, for example “Daily cleanup of expired sessions”.
  • Environment: where this job runs.
Functions your code gives a schedule are also added to the list when you deploy. Each job in the list has Run Now to run it straight away, a switch to pause it, and Delete, which asks first.

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.