@websolutespa/payload-plugin-cron-job
TypeScript icon, indicating that this package has built-in type declarations

1.7.4 • Public • Published

@websolutespa/payload-plugin-cron-job

npm version

status alpha

Cron job plugin for PayloadCms.

Payload Cron job Plugin

A plugin for Payload CMS that adds collections and UI components to manage cron jobs with activity logs.

Requirements:

  • Payload version 2.28.0 or higher is required.

Installation

npm i @websolutespa/payload-plugin-cron-job

Usage

import { buildConfig } from 'payload/config';
import { clearLogs, cronJob } from '@websolutespa/payload-plugin-cron-job';

export default buildConfig({
  plugins: [
    cronJob({
      jobs: {
        alwaysOn: {
          execute: (payload: Payload) => {
            console.log('ScheduledTask.alwaysOn every 5 minutes');
          },
          cron: '*/5 * * * *',
        },
        clearLogs: {
          execute: async (payload: Payload) => {
            console.log('ScheduledTask.clearLogs every sunday at 01:00');
            return await clearLogs(payload);
          },
          cron: '0 1 * * 0',
        },
      },
    }),
  ]
});

Plugin options

property description
jobs an object containing methods to run scheduled, each method is an object with an execute handler and a cron unix-cron string format

this library is for internal usage and not production ready

Dependencies (0)

    Dev Dependencies (16)

    Package Sidebar

    Install

    npm i @websolutespa/payload-plugin-cron-job

    Weekly Downloads

    21

    Version

    1.7.4

    License

    MIT

    Unpacked Size

    35.2 kB

    Total Files

    5

    Last publish

    Collaborators

    • websolute-admin
    • actarian
    • cbrualdi
    • federicodiluca
    • giacomo_grassetti
    • m.fort