0

I am trying to run this job in spring but i am getting an error

My intention is to run the job last Friday of every month

@EnableScheduling
@Service
 public class TestSchedular {
    @Scheduled(cron= "0 0 0 ? * 6L")
   public void schedular() {
    System.out.println("Cron Job");
}

Error:

Caused by: java.lang.IllegalStateException: Encountered invalid @Scheduled method 'schedular': For input string: "6L"

What is wrong with this code?

pvpkiran
  • 25,582
  • 8
  • 87
  • 134
  • Does this answer your question? [Cron Expression is not working for last day of the month](https://stackoverflow.com/questions/31445395/cron-expression-is-not-working-for-last-day-of-the-month) – pvpkiran Mar 26 '20 at 14:56

1 Answers1

1

Your cron expression ("0 0 0 ? * 6L") is invalid.

Spring's CronSequenceGenerator class has a method isValidExpression(String expression) which takes the cron expression and returns a boolean.

You could use that to check your Cron expression.

Marco Behler
  • 3,627
  • 2
  • 17
  • 19