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-guardian

v1.0.2

Published

A reliable cron job manager for Node.js applications with retries, monitoring, and job control

Readme

Smart Cron Manager

npm version Node.js Version TypeScript

A reliable cron job manager for Node.js applications with retries, monitoring, and job control.

Features

  • Cron Scheduling: Standard cron expressions with second precision
  • Named Jobs: Unique identifiers with duplicate prevention
  • Automatic Retries: Configurable retry logic with delays
  • Overlap Prevention: Prevent concurrent job executions
  • Execution Logging: Comprehensive logging with performance metrics
  • Failure Notifications: Custom callbacks for error handling
  • Runtime Control: Start, stop, and remove jobs dynamically
  • TypeScript Support: Full type definitions included

Installation

npm install cron-guardian

Requirements: Node.js ≥ 18.0.0

Quick Start

import { SmartCron } from 'cron-guardian';

const cronManager = new SmartCron();

// Schedule a simple job
cronManager.schedule('*/5 * * * *', async () => {
  console.log('Runs every 5 minutes');
});

// Schedule with advanced options
cronManager.schedule('0 */1 * * *', async () => {
  await processData();
}, {
  name: 'hourly-processor',
  retries: 3,
  retryDelay: 5000,
  preventOverlap: true,
  onFailure: (error, job) => {
    console.error(`Job ${job.name} failed:`, error.message);
  }
});

// Control jobs
cronManager.start('hourly-processor');
cronManager.stop('hourly-processor');
cronManager.remove('hourly-processor');

// Monitor
const jobs = cronManager.listJobs();
const logs = cronManager.getLogs();

API Overview

Core Methods

  • schedule(cronExpression, handler, options?) - Schedule a new job
  • start(jobName) - Start a stopped job
  • stop(jobName) - Stop a running job
  • remove(jobName) - Remove a job permanently
  • listJobs() - Get all scheduled jobs
  • getLogs() - Get execution logs

Job Options

  • name - Unique job identifier
  • retries - Number of retry attempts
  • retryDelay - Delay between retries (ms)
  • preventOverlap - Prevent concurrent executions
  • onFailure - Error callback function

Examples

Database Backup

cronManager.schedule('0 2 * * *', async () => {
  const backup = await createBackup();
  await uploadToS3(backup);
}, {
  name: 'daily-backup',
  retries: 3,
  retryDelay: 300000,
  preventOverlap: true,
  onFailure: (error) => sendAlert(`Backup failed: ${error.message}`)
});

API Health Check

cronManager.schedule('*/5 * * * *', async () => {
  const response = await fetch('https://api.example.com/health');
  if (!response.ok) throw new Error('API unhealthy');
}, {
  name: 'health-check',
  retries: 2,
  onFailure: (error) => console.error('Health check failed:', error.message)
});

Documentation

📖 Complete Documentation - Includes:

  • Detailed API reference
  • Advanced usage examples
  • Edge cases and error handling
  • Best practices
  • Troubleshooting guide
  • Performance considerations

Testing

# Run tests
npm test

# Build the project
npm run build

# Run example
node test-example.js

License

MIT License - see LICENSE file for details.

Contributing

Contributions welcome! Please see the contributing guidelines and complete documentation for details.


Version: 1.0.0 | Node.js: ≥18.0.0 | TypeScript: ≥4.0.0