2

My Java Web application has a Cron Job Scheduler which should trigger every hour starting from 7AM PST to 6PM PST. I am not getting how to specify PST time zone using zone parameter inside @Scheduled annotation. Kindly help

  @Component
  public class CronJobForFailedLoans {

      @Scheduled(cron ="0 0 7-18 ? * *")
     public void cronJobForFailedLoans()  {
    // Perform operations

 }  }
Karthik sa
  • 49
  • 7

1 Answers1

2

Your cron expression is valid just use Zone to specify the timezone, use online cron for validating and generating cron expression

@Scheduled(cron ="0 0 7-18 ? * *", zone="America/Los_Angeles")
Ryuzaki L
  • 37,302
  • 12
  • 68
  • 98
  • If I want to trigger the job for every 30 mintues between 7AM & 6PM PST , then which one is correct? 1. **@Scheduled(cron ="0 0/30 7-18 ? * *", zone="America/Los_Angeles") ** or 2. **@Scheduled(cron ="0 */30 7-18 ? * *", zone="America/Los_Angeles")** – Karthik sa Aug 08 '19 at 12:39
  • I tried with @Scheduled(cron ="0 0/30 3-4 ? * *", zone="America/Los_Angeles") , But the Job got triggered at 4.30 PM PST. Can somebody help me perfect answer. ? – Karthik sa Aug 12 '19 at 11:37
  • use this one `0 30 7-18 ? * *` @Karthiksa – Ryuzaki L Aug 12 '19 at 14:12