Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-cron

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-cron

A simple cron-like task scheduler for Node.js

  • 3.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.3M
decreased by-0.51%
Maintainers
1
Weekly downloads
 
Created

What is node-cron?

node-cron is a task scheduler for Node.js that allows you to schedule jobs (functions) to run at specific times or intervals using cron syntax. It is useful for automating repetitive tasks such as backups, email notifications, and data processing.

What are node-cron's main functionalities?

Basic Scheduling

This feature allows you to schedule a task to run at specific intervals using cron syntax. In this example, the task runs every minute.

const cron = require('node-cron');

cron.schedule('* * * * *', () => {
  console.log('Running a task every minute');
});

Specific Time Scheduling

This feature allows you to schedule a task to run at a specific time. In this example, the task runs every day at midnight.

const cron = require('node-cron');

cron.schedule('0 0 * * *', () => {
  console.log('Running a task every day at midnight');
});

Task Stopping

This feature allows you to stop a scheduled task. In this example, the task is scheduled to run every minute but is stopped immediately after being scheduled.

const cron = require('node-cron');

let task = cron.schedule('* * * * *', () => {
  console.log('Running a task every minute');
});

task.stop();

Task Starting

This feature allows you to start a scheduled task. In this example, the task is scheduled to run every minute and is started explicitly.

const cron = require('node-cron');

let task = cron.schedule('* * * * *', () => {
  console.log('Running a task every minute');
});

task.start();

Task Destruction

This feature allows you to completely destroy a scheduled task, removing it from the scheduler. In this example, the task is scheduled to run every minute but is destroyed immediately after being scheduled.

const cron = require('node-cron');

let task = cron.schedule('* * * * *', () => {
  console.log('Running a task every minute');
});

task.destroy();

Other packages similar to node-cron

Keywords

FAQs

Package last updated on 08 Nov 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc