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.

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

src/vitnode.api.config.ts
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 dev
pnpm dev
npm run dev

That'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.

CRON Jobs - VitNode