A MySQL-based periodic cron job system supporting async worker functions with automatic error handling and JSON result serialization. Version 1.0.1 requires Node.js 12+ and a MySQL database. It provides conditional job execution via SQL WHERE clauses, parallel job execution limits, stalled job detection, and retry logic. Unlike traditional cron, it stores job definitions and history in a MySQL table, enabling distributed scheduling and persistence. Full TypeScript support and comprehensive type definitions are included. Release cadence is irregular.
npm install node-mysql-cronNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Sets up a MySQL connection pool, configures the cron system, registers an async worker, and starts processing jobs.
Install mysql package: npm install mysql. Do not use mysql2 pool.
Ensure workers are async and return a plain object or primitive.
Execute the CREATE TABLE statement from the documentation before starting Cron.
Always call Cron.config() first, then register workers with Cron.setWorker(), and finally Cron.start().
Use default import: import Cron from 'node-mysql-cron' (ESM) or const Cron = require('node-mysql-cron') (CJS).Ensure you pass an object with 'pool' key pointing to a mysql connection pool. Example: Cron.config({ pool: myPool }).Run: npm install mysql