Migrate scheduled jobs
Move cron and interval vals to Easel Schedules.
Cron and interval vals become jobs that Easel Schedules runs on a cron expression. Easel Schedules is in beta.
Choose the schedule
Val Town ran cron expressions in UTC, and Easel does too by default, so a cron
val keeps its expression. An interval val ran a fixed time after its last run;
pick the cron expression closest to it, such as 0 * * * * for hourly. On
Hobby, a job runs at most every 15 minutes.
Create the job
In a project with a Hono app, schedule a route. Add a random CRON_SECRET to
the project's environment variables; each run sends it as a bearer token.
In a project without a Hono app, use a private function with
@vercel/schedules instead:
Make it safe to repeat
A run can be delivered twice and isn't retried if it fails. Record each run's ID before doing the work, and keep a watermark of the newest item processed so the next run catches up on anything missed:
lib/jobs/digest.ts
Interval vals tracked progress in lastRunAt, which Val Town doesn't export.
Seed the watermark from your data, such as the newest record the last run
handled.
Switch to production
Preview schedules start disabled, so test with Run Schedule in the project's Schedules tab. To switch:
- Disable the cron val, and wait for any running job to finish.
- Copy the final watermark and data to the production database.
- Deploy to production. The schedule starts enabled.
Back to the feature list.