Sequence NODE_234
EasySchedule a Repeating Task
Node.js
Technical Specification
Create a script that logs a heartbeat message every minute, and stops after 5 runs.
Input/Output Samples
Input:run script
Output:Heartbeat #1 ... Heartbeat #5 then exit
Optimal Logic Path
let count = 0;
const maxRuns = 5;
const id = setInterval(() => {
count++;
console.log("Heartbeat #", count);
if (count >= maxRuns) {
clearInterval(id);
}
}, 60000);Architectural Deep-Dive
Timers are useful for periodic background tasks like cleanups or sync jobs.