Schedule
Run server code at set times. One file deploys as cron on your host.
Deploys on
server/schedules/daily-report.tsSame on every host
import { defineSchedule } from 'vite-hub/schedule'
// Runs every day at 08:00 UTC.
export default defineSchedule({
cron: '0 8 * * *',
handler({ scheduledAt }) {
console.log('Report for', scheduledAt.toISOString())
},
})Deploy on
Node / Docker: process
One file per schedule
Create a file in
server/schedules. The file name is the schedule name. Cron uses UTC unless you set timeZone.Test without waiting
Run a Static Schedule by hand with
vitehub schedule run or from the Console, unless it sets manual: false.