Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

261
Visualizações
node-cron jobs list wont stop

Ive got an array of cron jobs in my project which trigger at different times. I want to ability to stop all of these jobs when an event is triggered and for them not to start again until also manually triggered.

My issue is, i can stop my jobs, but then they appear to start themselves back up again..

Ive confirmed this by adding an addition cron which just checks the status regularly. Initially, the status is 'scheduled', then when i trigger to stop the status changes to 'stoped' which is correct, and then after sometime each one will eventually update its status to 'scheduled' again. Whats doing this? Is there another way I can disable these jobs so they stay stopped until ive manually started them?

const cron = require('node-cron');

jobs.push(cron.schedule('5 1 * * 1,4', () => {
  func.runOne();
}));

jobs.push(cron.schedule('0 1 * * *', () => {
  func.runTwo();
}));

jobs.push(cron.schedule('0 2 * * *', () => {
  func.runThree();
}));

jobs.push(cron.schedule('30 2 * * *', () => {
  func.runFour();
}));


cron.schedule('*/10 * * * * *', () => {
  console.log(`checking the status of jobs for task`);
  jobs.forEach((job) => {
    console.log(`Job status is: ${job.getStatus()}`);
  });
});

exports.stopJobs = () => {
  jobs.forEach((job) => {
    job.stop();
  });
};

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda