taskschedulerbythinker2288
v1.0.3
Published
by Thinker2288
Downloads
4
Readme
Task Scheduler
Task Scheduler is a simple Node.js package for scheduling tasks using cron expressions.
Installation
To install Task Scheduler, use npm:
npm install task-scheduler
Usage
- Import the package in your Node.js application:
const taskScheduler = require('task-scheduler');
- Define your tasks with schedule patterns and actions:
const tasks = [
{ id: 1, name: 'Task 1', schedule: '*/5 * * * * *', action: () => console.log('Task 1 executed') },
{ id: 2, name: 'Task 2', schedule: '*/10 * * * * *', action: () => console.log('Task 2 executed') },
];
- Initialize the task scheduler with your tasks:
taskScheduler.initialize(tasks);
Sample Usage
Here's a simple example of using the Task Scheduler package:
const taskScheduler = require('task-scheduler');
const tasks = [
{ id: 1, name: 'Task 1', schedule: '*/5 * * * * *', action: () => console.log('Task 1 executed') },
{ id: 2, name: 'Task 2', schedule: '*/10 * * * * *', action: () => console.log('Task 2 executed') },
];
taskScheduler.initialize(tasks);
Cron Expressions
Task Scheduler uses cron expressions to define task schedules. You can use cron syntax to set the schedule patterns for your tasks. For more information on cron expressions, refer to Cron Expression Syntax.
License
This project is licensed under the MIT License - see the LICENSE file for details.