
Company News
Free Business Plan Upgrades for Open Source Maintainers
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.
@yuo/node-cron
Advanced tools
npm install @yuo/node-cron
# ┌────────────── 秒 (可选)
# │ ┌──────────── 分
# │ │ ┌────────── 时
# │ │ │ ┌──────── 日
# │ │ │ │ ┌────── 月
# │ │ │ │ │ ┌──── 周 (0-7), 0和7表示周日
# │ │ │ │ │ │
# │ │ │ │ │ │
# * * * * * *
| field | value |
|---|---|
| 秒 | 0-59 |
| 分 | 0-59 |
| 时 | 0-23 |
| 日 | 1-31 |
| 月 | 1-12 |
| 周 | 0-7 (周日 0, 7 ) |
import { schedule } from '@yuo/node-cron';
cron.schedule('1,2,4,5 * * * *', () => {
console.log('在每小时中的第 1、2、4、5 的分钟整点各触发一次');
});
cron.schedule('1-5 * * * *', () => {
console.log('在每小时中的第1~5分钟中, 每分钟触发一次');
});
import { schedule } from '@yuo/node-cron';
schedule('*/2 * * * *', () => {
console.log('间隔2分钟执行一次');
});
schedule('10/2 * * * * *', () => {
console.log('从每分钟的第10秒开始, 间隔2秒钟执行一次');
});
import { schedule } from '@yuo/node-cron';
// 默认scheduled: true, 是直接开启的, 不需要手动start
const task1 = schedule('* * * * *', (flag: string) => {
// doSomething
if (flag === 'manual') {
// 检测到手动触发后, 注销事务
task1.stop();
}
}, { scheduled: false });
task1.start();
task1.now('manual');
// fork子进程启动, 相对于根目录(node启动时的目录)
const task2 = schedule('* * * * *', './schedule-1.ts');
// ./schedule-1.ts, 文件形式的事务无入参
import { yourNBUtil } from 'util';
export default () => {
let shit = yourNBUtil.doSomething();
};
import { schedule } from '@yuo/node-cron';
const task = schedule('* * * * *', () => {
console.log('will execute every minute until stopped');
});
task.stop();
import { validate } from '@yuo/node-cron';
const res1 = validate('59 * * * *'); // valid
const res2 = validate('60 * * * *'); // invalid 0~59
FAQs
task scheduler for glede-server
The npm package @yuo/node-cron receives a total of 6 weekly downloads. As such, @yuo/node-cron popularity was classified as not popular.
We found that @yuo/node-cron demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.

Security News
During a UK cyber test, a Mythos 5 agent used sockpuppets, social engineering, and prompt injection to try to get a maintainer to merge malware.