crontab-node

3.0.1 • Public • Published

crontab-node

yarn add crontab-node

crontab-node目的是配合linux的crontab使用, 需要每分钟执行一次,时间触发后才会执行函数方法

kernel

Example

c.js

const crontab = require('crontab-node');
const eventEmitter = require('crontab-node/eventEmitter');

eventEmitter.on('crontab-node exit', () => {
    process.exit(0);
});
const promise = new Promise((resolve, reject) => {
    setTimeout(() => {
      resolve();
    }, 1);
});

console.log(new Date());

crontab('*/2 * * * *', () => {
    return promise.then(() => {
        console.log('I am callback, just excute once');
    });
});

crontab -l

* * * * * node path/c.js

Dependencies (2)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i crontab-node

    Weekly Downloads

    4

    Version

    3.0.1

    License

    MIT

    Unpacked Size

    80.8 kB

    Total Files

    9

    Last publish

    Collaborators

    • luoage