Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

474
Views
How to schedule cron job to run only once at a specific date (with year) using node-cron?

I'm new to cron and actually not sure if node-cron is the right npm package for me. Basically, I just want to create a scheduled post feature in my app. Where I can set a time to post my content in the future.

So I discovered node-cron and was able to play around with it. I can get it to work, but I noticed this kind of scheduling in node-cron is about setting intervals, and your function is set to repeat again and again. Correct me if I'm wrong.

But let's say I'd like to console.log("Hello World") on Feb, 24, 2023 and run it only once. If I set that on the cron string(not sure what you call it), then I guess I would set it like this:

    cron.schedule("* * * 24 Feb *", ()=>{
        console.log("Hello World")
    })

There is no option to specify a year as I read on the documentation, so where I can I specify the year? My code above will run every second on every Feb, 24 in any year right? Don't mind "the every second run" on my code above, but what I wanted to do is to specify the exact date and year for it to run, within that specific date only.

I've read about node-schedule package where you can pass dates as the schedule, but it seems node-schedule only runs when the script is running?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!