Socket
Socket
Sign inDemoInstall

@types/cron

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/cron

Stub TypeScript definitions entry for cron, which provides its own types definitions


Version published
Maintainers
1
Created

What is @types/cron?

@types/cron provides TypeScript type definitions for the cron package, which is used for scheduling jobs in Node.js applications. It allows developers to define and manage cron jobs with type safety.

What are @types/cron's main functionalities?

Creating a Cron Job

This feature allows you to create a cron job that runs a specified function at a scheduled time. In this example, the job is scheduled to run every day at midnight.

const cron = require('cron');
const CronJob = cron.CronJob;
const job = new CronJob('0 0 * * *', function() {
  console.log('You will see this message every day at midnight');
});
job.start();

Stopping a Cron Job

This feature allows you to stop a running cron job. In this example, the job is stopped after 10 seconds.

const cron = require('cron');
const CronJob = cron.CronJob;
const job = new CronJob('0 0 * * *', function() {
  console.log('You will see this message every day at midnight');
});
job.start();
// Stop the job after some time
setTimeout(() => {
  job.stop();
  console.log('Job stopped');
}, 10000);

Specifying Time Zones

This feature allows you to specify the time zone for the cron job. In this example, the job is scheduled to run every day at midnight in the 'America/Los_Angeles' time zone.

const cron = require('cron');
const CronJob = cron.CronJob;
const job = new CronJob({
  cronTime: '0 0 * * *',
  onTick: function() {
    console.log('You will see this message every day at midnight in the specified time zone');
  },
  timeZone: 'America/Los_Angeles'
});
job.start();

Other packages similar to @types/cron

FAQs

Package last updated on 02 Aug 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