CRON Jobs
Automate and manage recurring tasks in your VitNode app with cron jobs — perfect for cleanups, emails, reports, and more.
Adapters
Before you can use cron functionality, you need to provide an adapter to your application.
REST API
Run cron jobs by triggering REST API endpoints from an external scheduler.
Node CRON
In-memory tiny task scheduler in pure JavaScript for node.js based on GNU crontab.
Custom adapter
VitNode supports custom cron adapters, allowing you to integrate with various scheduling libraries or services.
Create your custom adapter
As an example we will create a custom adapter using the popular node-cron library.
import { schedule } from "node-cron";
import { type CronAdapter, handleCronJobs } from "@/api/lib/cron";
export const NodeCronAdapter = (): CronAdapter => {
return {
schedule() {
schedule("*/1 * * * *", async () => {
await handleCronJobs();
});
}
};
};Integrate the adapter into your application
import { NodeCronAdapter } from "./path/to/your/custom/node-cron.adapter";
export const vitNodeApiConfig = buildApiConfig({
cronAdapter: NodeCronAdapter()
});Restart server
After making these changes, stop your server (if it's running) and restart it to apply the new configuration.
bun devpnpm devnpm run devThat's it — your app now has a built-in task scheduler, ready to handle cron jobs with standard cron expressions.
Check Your Cron Jobs
You can check your cron jobs in AdminCP under Core => Advanced => Cron Jobs.