npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cron-task-manager

v1.0.0

Published

A production-ready, dependency-free cron job scheduler and manager for Node.js featuring overlap protection, detailed execution stats, error recovery, and status checks.

Readme

cron-task-manager

A production-ready, dependency-free cron job scheduler and manager for Node.js. It features overlap protection, detailed runtime metrics, custom error callbacks, manual execution, and support for standard 5-field cron patterns.

Features

  • 🚀 Zero dependencies — extremely fast, lightweight, and reliable.
  • 🔀 Overlap Protection — prevents a job from running again if the previous execution is still running (highly critical for async database tasks, sync scripts, etc.).
  • 📊 Detailed Execution Stats — tracks total runs, success/failure counts, skipped executions, last run timestamp, and last execution duration.
  • 🪝 Custom Error Hooks — register a callback to handle task exceptions gracefully.
  • Manual Triggering — run any registered task programmatically on-demand.
  • 📅 5-Field Cron Support — supports standard cron matching: minute, hour, day-of-month, month, day-of-week. (Supports *, steps */n, lists a,b, and ranges a-b).

Installation

npm install cron-task-manager

Quick Start

const { CronTaskManager } = require('cron-task-manager');
const scheduler = new CronTaskManager();

// 1. Add an async task running every minute
scheduler.add(
  'syncData', 
  '* * * * *', 
  async () => {
    console.log('Syncing data with remote server...');
    await new Promise(resolve => setTimeout(resolve, 2000));
  },
  {
    allowOverlap: false, // Prevent starting again if previous execution is still running
    onError: (err) => console.error('Error in syncData task:', err)
  }
);

// 2. Start the scheduler loop
scheduler.start();

// Get statistics
console.log(scheduler.list());

Advanced Usage

Manual Triggering

You can run any task immediately by name without waiting for its scheduled time:

await scheduler.runTask('syncData');

Checking Task Metrics

const tasks = scheduler.list();
console.log(tasks[0].stats);
/* Output:
{
  totalRuns: 5,
  successRuns: 4,
  failedRuns: 1,
  skippedRuns: 0,
  lastRunTime: '2026-06-28T01:50:00.000Z',
  lastDurationMs: 2045,
  lastError: 'Database timeout'
}
*/

Cron Patterns Support

The scheduler parses standard 5-field expressions:

┌────────────── minute (0 - 59)
│ ┌──────────── hour (0 - 23)
│ │ ┌────────── day of month (1 - 31)
│ │ │ ┌──────── month (1 - 12)
│ │ │ │ ┌────── day of week (0 - 6) (0 is Sunday)
│ │ │ │ │
* * * * *
  • */5 * * * *: Every 5 minutes.
  • 0 9 * * 1-5: At 9:00 AM, Monday through Friday.
  • 0,30 9-17 * * *: At minute 0 and 30, between 9 AM and 5 PM daily.

License

MIT