Skip to content

isRecurringJob

function isRecurringJob<T>(job): boolean;

Defined in: packages/core/src/jobs/guards.ts:218

Type guard to check if a job is a recurring scheduled job.

A recurring job has a repeatInterval cron expression and will be automatically rescheduled after each successful completion.

Type ParameterDescription
TThe type of the job’s data payload
ParameterTypeDescription
jobJob<T>The job to check

boolean

true if the job has a repeatInterval defined

const jobs = await monque.getJobs();
const recurringJobs = jobs.filter(isRecurringJob);
console.log(`${recurringJobs.length} jobs will repeat automatically`);
if (!isRecurringJob(job) && isCompletedJob(job)) {
  // Safe to delete one-time completed jobs
  await deleteJob(job._id);
}