Cron jobs
Schedule HTTP routes or Cloudflare Worker scheduled handlers.
Arkor runs HTTP route jobs for Next.js deployments and Cloudflare Worker scheduled() handlers
for native Workers and supported frameworks. Both use UTC schedules and run only for the
production deployment being served.
For a Next.js HTTP job, declare paths in a vercel.json at the root of your app, as on Vercel;
an app that already has one needs no change.
{
"crons": [
{ "path": "/api/cron/cleanup", "schedule": "0 3 * * *" },
{ "path": "/api/cron/sync", "schedule": "*/15 * * * *" }
]
}The jobs take effect when the deployment that declares them is published, and are replaced by the
next deployment's. Only crons is read from vercel.json; routing, headers and redirects come from
next.config.
Cloudflare scheduled handlers
For a native Worker or a framework that builds to a Cloudflare Worker, declare schedules in its Wrangler configuration:
{
"triggers": {
"crons": ["*/15 * * * *", "59 23 LW * *"]
}
}Export the handler from your Worker entrypoint:
export default {
async scheduled(controller: ScheduledController, env: Env, ctx: ExecutionContext) {
if (controller.cron === '59 23 LW * *') {
await env.JOBS.put('last-monthly-run', String(controller.scheduledTime));
}
ctx.waitUntil(runCleanup(env));
},
};A default class extending WorkerEntrypoint is also supported; its scheduled(controller)
method reads bindings and context through this.env and this.ctx.
- Each invocation receives the exact declared expression in
controller.cron, its due timestamp incontroller.scheduledTime, and the deployment's environment and resource bindings. - Awaited work and
ctx.waitUntil()work contribute to the result. A rejection marks the run failed. The exportedwaitUntil()fromcloudflare:workersis supported too. - No public route or
CRON_SECRETis required. Project access protection does not gate these jobs. - Arkor gives each invocation up to 5 minutes. Cloudflare's own Cron Trigger ceiling is 15 minutes; Arkor's execution limit remains five minutes.
- Delivery is best effort, without retries or replaying every missed interval. An overdue invocation may run once late. Jobs must tolerate duplicates and overlap when an earlier invocation is still running.
These schedules use Cloudflare's cron dialect:
five fields, case-insensitive month/weekday names, and L, W and # extensions.
Weekdays are 1 = Sunday through 7 = Saturday. Both day fields may be restricted; a date matches
when either matches. The ? character and @daily shortcuts are unsupported. Up to 100 jobs may
be declared per project.
The handler is prepared separately during deployment. Adding schedules does not add a request hop or scheduler lookup to visitor traffic. Schedules follow publication, rollback and release restoration; preview deployments do not register jobs.
Secure an HTTP path
Add a CRON_SECRET environment variable and deploy. Each
call then carries authorization: Bearer <CRON_SECRET>; refuse any request without it:
export async function GET(request: Request) {
if (request.headers.get('authorization') !== `Bearer ${process.env.CRON_SECRET}`) {
return new Response('Unauthorized', { status: 401 });
}
// … the job
return Response.json({ ok: true });
}Without CRON_SECRET, calls carry no authorization header.
HTTP schedules
A schedule has five fields, in UTC: minute, hour, day of month, month and day of week.
- Use numbers: names such as
MONorJAN, and shortcuts such as@daily, are not accepted. - Day of month and day of week cannot both name days: when one does, the other must be
*. - A project may have up to 100 jobs. The same path on two schedules is two jobs.
A schedule Arkor cannot run fails the build, and the log names the file and the field.
How an HTTP job is called
- A
GETrequest tohttps://<project>.arkor.app<path>, with the headersx-vercel-cron-schedule(andx-arkor-cron-schedule) holding the schedule, anduser-agent: arkor-cron/1.0. - Once: a call is not retried, and a redirect is not followed. A call Arkor could not make on time may be made once, late; the times missed in between are not made up. Write each job so that running late, running twice or missing a run is safe.
- Only the production deployment's jobs run; a preview deployment's are not registered.
- It is called at the
arkor.appaddress, not at a custom domain. If your middleware redirects that address to your domain, let the job's path through. - A call that has no answer within 5 minutes is given up on.
- Each call counts as a request of your app, like any other.
- With access protection on, calls pass the gate on their own.
If your app also has an upwind.config.ts, upwind.jsonc or upwind.json, the jobs are read
from that file instead of vercel.json.
Check the jobs
Cron jobs, in the project's sidebar, lists each Target, Schedule, Last run and Next run. HTTP targets show their path and response status, or No response when the call failed or was given up on. Cloudflare targets show scheduled(), with Completed or Failed as their result. Run times use your time zone; schedules stay in UTC.
While a project that has jobs is not being served, the page says Cron jobs are paused above them. When serving resumes, an overdue job may run once late, then follow its schedule again; missed occurrences are not all replayed.
For what an HTTP run printed, search the project's Logs for its path.
Output from scheduled() handlers also appears in Logs, labelled cron. Search by the declared
schedule expression to find its runs.