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

145
Views
Using my own logic to run cron job only once at the specified date/time. Will the cron listener continue to run though?

I am using and new to node-cron. So I was able to set and run a function on the scheduled time/date I specified. What I read is that we cannot set a year in cron jobs, so I made my code like this.

const cron = cronTest.schedule(
  '39 20 29 March *',
  () => {
    console.log('successfully ran');
  },
  { scheduled: false }
);

if (new Date().getFullYear() == req.body.scheduledYear) {
  cron.start();
}

So in the future date March 29, 8:39 PM, it will output 'successfully ran' in the console, if the current year is equal or now equal to the year set in scheduledYear variable.

My question is, after all that, on the next March 29, 8:39 PM on the following year, will my cron job be running again? If yes, I know it will never output my console.log which is what I wanted in the first place, but the concern is if there is still some listener or watcher running in the background on the server waiting for another March 29, 8:39 PM to come up?

How would I know if there are cron related events running in my server? Is my code above fine, and will not cause performance issues? I'm not so familiar how server works, but please let me know if what I'm doing here is very wrong.

Thanks.

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!