CRON jobs
CRON jobs are jobs that run on a given interval. This is useful for tasks that need to run periodically, like sending emails, cleaning up old data, or updating a cache.
Creating a CRON job
First, you'll want to make sure you have your job configured in your job router. There is no special syntax for CRON jobs; they are just like any other job.
// api/queuebase/core.ts
export const jobRouter = {
sendWeeklyReport: j().handler(async () => {
console.log("Sending weekly report...");
}),
} satisfies QueuebaseJobRouter;
Next, you'll want to navigate to the scheduled jobs (opens in a new tab) page dashboard and create a new scheduled job.
When creating a CRON job, you'll need to provide the following information:
- A unique name for the job
- A valid CRON expression (opens in a new tab)
- The route for the job
When selecting a job route, you'll get a list of all jobs that have been created and run in Queuebase. If you don't see your job, you can either run a job sync or manually enter the route. The route name MUST match the route you defined in your job router.
Running your job
After you save your CRON job, we take it from here. We'll run your job on the interval you specified. You can view the status of your job in the dashboard. CRON job runs are treated as normal job runs, so you can view the logs status, and payload of each run.