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

cron

Package Overview
Dependencies
Maintainers
3
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cron

Cron jobs for your node

  • 3.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.7M
decreased by-17.53%
Maintainers
3
Weekly downloads
 
Created

What is cron?

The cron npm package is used for scheduling tasks to be executed at specific times or intervals. It is inspired by the Unix cron scheduler and allows for the use of cron syntax to schedule tasks in a Node.js environment. This package is useful for setting up jobs like backups, sending emails, or cleaning up databases at regular intervals.

What are cron's main functionalities?

Basic Cron Job

This feature allows you to create a basic cron job that runs at a specified interval. In the provided code sample, a new CronJob is created that logs a message to the console every second.

"const CronJob = require('cron').CronJob;\nconst job = new CronJob('* * * * * *', function() {\n  console.log('You will see this message every second');\n}, null, true, 'America/Los_Angeles');\njob.start();"

Time Zone Support

This feature demonstrates the ability to specify a time zone for the cron job. The code sample schedules a job to run at 11:30 AM, according to the 'America/New_York' time zone, from Monday to Friday.

"const CronJob = require('cron').CronJob;\nconst job = new CronJob('00 30 11 * * 1-5', function() {\n  console.log('This runs at 11:30 AM (server time) every Monday through Friday.');\n}, null, true, 'America/New_York');\njob.start();"

Dynamic Job Scheduling

This feature allows for dynamic scheduling of jobs. The schedule can be updated or changed based on certain conditions or inputs. In the example, the 'dynamicSchedule' variable can be updated to change the job's schedule.

"const CronJob = require('cron').CronJob;\nlet dynamicSchedule = '00 30 11 * * 1-5'; // This can be dynamically changed\nconst job = new CronJob(dynamicSchedule, function() {\n  console.log('This job's schedule can be dynamically changed.');\n}, null, true, 'America/Los_Angeles');\njob.start();"

Other packages similar to cron

Keywords

FAQs

Package last updated on 12 Nov 2024

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