New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

evercron

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

evercron

MongoDB-persistent job scheduler

latest
npmnpm
Version
1.0.1
Version published
Maintainers
0
Created
Source

EverCron – Persistent MongoDB Job Scheduler

npm
License

Persistent cron jobs for Node.js with MongoDB storage.
Survives server restarts and supports flexible scheduling.

🚀 Quick Start

1. Install

npm install evercron mongodb

2. Basic Usage

const { MongoClient } = require('mongodb');
const EverCron = require('evercron');

(async () => {
  // 1. Connect to MongoDB
  const client = await MongoClient.connect('mongodb://localhost:27017');
  const jobs = client.db('myapp').collection('cronJobs');

  // 2. Create scheduler
  const scheduler = new EverCron(jobs);

  // 3. Schedule jobs
  await scheduler.schedule(
    'nightly-backup', 
    'daily at 02:00',
    backupDatabase,
    { timezone: 'Asia/Kolkata' }
  );
})();

🕒 Schedule Formats

TypeExampleDescription
Interval'every 30 minutes'Recurring duration
Daily'daily at 15:30'Specific time daily
Cron'0 * * * *'Standard cron syntax

🔧 API Reference

schedule(name, schedule, taskFn, options)

Schedule a new job.

await scheduler.schedule(
  'weekly-report',
  '0 9 * * 1', // Every Monday at 9 AM
  generateReport,
  { 
    maxRetries: 3,
    timezone: 'America/Chicago' 
  }
);

cancel(name)

Cancel a scheduled job.

await scheduler.cancel('obsolete-job');

restore()

Restore scheduled jobs after a server restart.

await scheduler.restore();

🧪 Testing in Development

Manually Trigger a Job

await scheduler.schedule(
  'test-job',
  'every 1 minute', 
  testTask,
  { timezone: 'UTC' }
);

📄 List All Jobs

const jobs = await jobsCollection.find().toArray();
```---

## 🧪 How to Test Jobs in Development?

### Manually Trigger a Job

```js
await scheduler.schedule(
  'test-job',
  'every 1 minute', 
  testTask,
  { timezone: 'UTC' }
);

📋 How to List All Jobs?

const jobs = await jobsCollection.find().toArray();

Keywords

cron

FAQs

Package last updated on 25 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts