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

160
Views
How cancel scheduled jobs using BreeJS

I have an express server that starts a reoccurring job upon client request for a specified amount of time, the issue I'm facing is: How can I stop and remove that specific job after completion.

The code that I have is

// do the request logic
// generate the job ID
// save the job ID with repetition amount in mongoose
bree.add({
    name: jobID,
    interval : "30s",
    path : "./jobs/example_job.js",
    worker: {
    workerData: {
        jobID: jobID,
        }},
    })
bree.start(jobID)

and for the example_job.js

const thread = require("worker_threads") // for the jobID

// performs some logic
// reduce repetition amount
if(module.repetitionAmout == 0)
{
// delete the mongoose module
// stop the function with name jobID
}

My issue is with // stop the function with name jobID. how can I achieve that? I've tried process.exit(0) but that only exits the thread and doesn't stop it from repeating again I've also tried exporting and importing the bree instance to the example_job.js and passing the jobID to cancel it there but that also did not work, anyone has any experience with canceling jobs?

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!