Search code examples
javacronquartz-schedulerquartz

Why is my quartz job not getting triggered according to given cron expression, instead firing every 10 minutes?


I am trying to create a job which will run every Saturday at 8 pm using cron expression input to the trigger scheduler. But my job is getting executed every 10 minutes? What on earth have I done wrong here, please help. My app setup stack is Spring Boot + Hibernate. The code is as follows.

    @Bean(name = "emailReportJobDetail")
    public JobDetail emailReportJobDetail() {
        return newJob().ofType(EmailReportJob.class).storeDurably().withIdentity(JobKey.jobKey("Qrtz_EmailReportProcessor")).withDescription("Invoke EmailReportProcessor Job service...").build();
    }

    @Bean
    public Trigger emailReportTrigger(@Qualifier("emailReportJobDetail") JobDetail job) {

        logger.info("Configuring emailReportTrigger to fire every Saturday 8 PM GMT");

        return newTrigger().forJob(job).withIdentity(TriggerKey.triggerKey("Qrtz_EmailReportProcessor")).withDescription("EmailReportProcessor trigger")
                .withSchedule(CronScheduleBuilder.cronSchedule("0 0 20 ? * SAT")
                )
                .build();
    }

Solution

  • most of time you have a job with the same name in the database, which must be updated by another member of the cluster.

    Either you could try to rename your job (jobkey), or check if the database is not used by someone else.

    Nevertheless, a job update its configuration at startup.