Cron jobs for Node.js applications that enables developers to execute functions or system commands on schedules defined using standard cron syntax
94
Build a simple task reminder system that executes scheduled tasks at specific times using cron-based scheduling.
Create a task reminder system with the following functionality:
Task Scheduling: The system should allow scheduling tasks to run at specific intervals defined by cron expressions.
Task Execution: When a scheduled time arrives, the system should execute a callback function that logs a reminder message to the console with the format: "REMINDER: [task name] - [message]".
Task Control: The system should support:
Multiple Tasks: The system should be able to manage multiple independent scheduled tasks simultaneously.
Create a module that exports the following:
A function createReminder(name, message, schedule, autoStart) that creates a new task reminder
name: string identifier for the taskmessage: the reminder message to displayschedule: a cron expression string (e.g., "*/5 * * * * *" for every 5 seconds)autoStart: boolean indicating whether to start the task immediately (default: false)start() and stop() methodsA function createDailyReminder(name, message, hour, minute) that creates a daily reminder at a specific time
name: string identifier for the taskmessage: the reminder message to displayhour: hour of day (0-23)minute: minute of hour (0-59)start() and stop() methods@generates
/**
* Creates a task reminder that executes on a schedule
* @param {string} name - The task identifier
* @param {string} message - The reminder message
* @param {string} schedule - Cron expression for scheduling
* @param {boolean} autoStart - Whether to start immediately (default: false)
* @returns {{start: Function, stop: Function}} Control object with start and stop methods
*/
function createReminder(name, message, schedule, autoStart = false) {
// Implementation here
}
/**
* Creates a daily reminder at a specific time
* @param {string} name - The task identifier
* @param {string} message - The reminder message
* @param {number} hour - Hour of day (0-23)
* @param {number} minute - Minute of hour (0-59)
* @returns {{start: Function, stop: Function}} Control object with start and stop methods
*/
function createDailyReminder(name, message, hour, minute) {
// Implementation here
}
module.exports = {
createReminder,
createDailyReminder
};Provides job scheduling functionality with cron expressions.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-cronevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10