Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including schedule-jobs-with-cron with all npm packages installed. Try it out:

/* * This is a how to use live example */ // Import the library const { CronJob } = require('schedule-jobs-with-cron'); // Let's define an end date in one minute, we don't want this demo to run forever const now = new Date(); const endInMinutes = 1; const endDate = new Date(now.getTime() + endInMinutes * 60000); // Define and schedule a new job const job1 = new CronJob( 'A test Job 1', (triggerTime, log) => { log('info', `Hello from inside the job, it was triggered at: ${triggerTime}`); /*** Add code that does some work here ***/ }, // A cron schedule that runs every minute '* * * * *', { endDate: endDate, }, ); // Await for the job. // Non-blocking; other functions can run in the meantime, // but any further lines in this one won't start until the promise resolves. await job1.getPromise(); console.log('done'); /**** watch for console log output below ****/

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

schedule-jobs-with-cron v1.5.4

Schedule jobs with cron specifications

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free