'How to run cron job every minute in Queue using Workers with bullmq package in nodejs?

    import { Queue, Worker, Job } from 'bullmq';

const myQueue = new Queue('firstjob', { connection: redis });
    import { autorunJobs } from './processes/job.process';
    
async function addQueue() {
    await myQueue.add(
        'autoclosejob',
        {
            repeat: {
                cron: '* * * * *'
            },
        },
    );
}

addQueue();

const worker = new Worker('firstjob', async (job: Job) => {
    console.info('Started.');
   await autorunJobs();
    console.info('Closed.');
    //return true;
}, { connection: redis });
worker.run();

When I run this code, it executes successfully at once. But after I wait for the worker to run it again in the next minute but it doesn't. What I see is only one-time console.log output.

Following are one-time output logs:

Tue, 10 May 2022 12:21:12 GMT | IDM Service | INFO |    Started.
dta = "some data"
Tue, 10 May 2022 12:21:12 GMT | IDM Service | INFO |      Closed.

I want this output after every minute.

What I am doing wrong?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source