Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

475
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda