@abtnode/cron

1.16.25 • Public • Published

Cron Scheduler

A simple wrapper around cron to manage jobs in ABT Node

Usage

yarn add @abtnode/core

Then:

const Cron = require('@abtnode/cron');

const fetchIp = () => console.log('fetching ip...');

// Initialize cron scheduler
Cron.init({
  context: {},
  jobs: [
    {
      name: 'refetch-ip',
      time: '0 */30 * * * *', // refetch every 30 minutes
      fn: fetchIp,
    },
  ],
  onError: (error, name) => {
    console.log(`Run job ${name} failed with error: ${error.message}`);
  },
});

Readme

Keywords

none

Package Sidebar

Install

npm i @abtnode/cron

Weekly Downloads

639

Version

1.16.25

License

Apache-2.0

Unpacked Size

4.7 kB

Total Files

6

Last publish

Collaborators

  • wangshijun
  • polunzh
  • mave99a