A plugin to schedule cron jobs
https://en.wikipedia.org/wiki/Cron
$ npm i --save fastify-crons
fastify.register(require('fastify-crons'), {
timezone: 'Europe/Rome'
})
fastify.crons.schedule('*/2 * * * *', () => {
console.log('Hi!')
})
// OR:
const task = fastify.crons.schedule('*/2 * * * *', () => {
console.log('Hi!')
}, {
scheduled: false
})
task.start()
Under the hood, node-cron is used.
Name | Description |
---|---|
timezone |
Can be used to set the global reference timezone for all scheduled jobs. By default is UTC. |
$ npm test
This project is kindly sponsored by:
Licensed under MIT