
Company News
AWS Security Hub Adds Socket for Supply Chain Security
Socket is now in the AWS Security Hub Extended plan. Adopt it through AWS, apply committed spend, and block malicious open source packages.
@monlite/cron
Advanced tools
Cron-style job scheduling for @monlite/core: persisted schedules, 5-field cron, multi-process safe.
Cron-style scheduling for @monlite/core,
backed by SQLite. Persisted schedules survive restarts, a zero-dependency 5-field cron parser,
and atomic firing so multiple processes won't double-run the same occurrence.
npm install @monlite/core @monlite/cron
import { createDb } from "@monlite/core";
import { createCron } from "@monlite/cron";
const db = createDb("app.db");
const cron = createCron(db);
cron.schedule("cleanup", "0 3 * * *", async () => {
await purgeOldRows(); // runs every day at 03:00 local time
});
cron.on("error", (err, name) => console.warn(name, err));
Standard 5-field format: minute hour day-of-month month day-of-week
| Pattern | Meaning |
|---|---|
* * * * * | Every minute |
*/15 * * * * | Every 15 minutes |
0 9 * * 1 | Monday 09:00 |
0 9-17 * * * | Hourly, 9am–5pm |
0 0 1,15 * * | 1st and 15th at midnight |
Day-of-week is 0–6 (0 = Sunday). Times are local. When both day-of-month and day-of-week
are restricted, either match fires (POSIX behavior).
const cron = createCron(db, {
checkInterval: 1000, // poll cadence in ms (default: 1000)
});
cron.schedule(name, cronExpr, handler); // register or update a schedule, start firing
cron.unschedule(name); // remove a schedule
cron.next(name); // next run as epoch ms, or undefined
cron.on("error", (err, name) => {});
cron.stop(); // stop firing (schedules remain in the db)
// Utility
import { nextCronRun } from "@monlite/cron";
nextCronRun("0 9 * * 1"); // → Date of the next Monday 09:00
Firing is atomic — each occurrence is claimed from the schedule row, so running the same schedule in multiple processes fires each occurrence exactly once.
@monlite/queueA cron handler runs in-process. For durable work that survives crashes and gets retried, have the
handler enqueue a job into @monlite/queue
instead of doing the work directly:
import { createQueue } from "@monlite/queue";
const queue = createQueue(db);
queue.process("report", async (job) => generateReport(job.payload));
cron.schedule("nightly-report", "0 0 * * *", () => {
queue.add("report", { day: new Date().toISOString() });
});
The schedule is persisted; the work is durable and retried.
MIT
FAQs
Cron-style job scheduling for monlite: persisted schedules, 5-field cron, multi-process safe — on SQLite (@monlite/core) or Postgres (@monlite/postgres).
The npm package @monlite/cron receives a total of 24 weekly downloads. As such, @monlite/cron popularity was classified as not popular.
We found that @monlite/cron demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Company News
Socket is now in the AWS Security Hub Extended plan. Adopt it through AWS, apply committed spend, and block malicious open source packages.

Research
/Security News
Popular npm packages keyv and cacheable compromised.

Security News
A misconfiguration gave three Anthropic models internet access, and one, believing it was in a simulation, shipped a credential-stealing package to PyPI.