Add support for disabled cron expression "-"
See original GitHub issueAccording to the docs, db-scheduler supports
Spring-style cron-expression.
However, a Spring cron expression of “-” means the task will never run, which is useful for disabling a task in a local/test environment.
I tried this expression with db-scheduler, but it caused this exception:
Caused by: java.lang.IllegalArgumentException: Cron expression contains 1 parts but we expect one of [6]
at com.github.kagkarlsson.shaded.cronutils.parser.CronParser.parse(CronParser.java:120) ~[db-scheduler-10.3.jar:na]
at com.github.kagkarlsson.scheduler.task.schedule.CronSchedule.<init>(CronSchedule.java:46) ~[db-scheduler-10.3.jar:na]
at com.github.kagkarlsson.scheduler.task.schedule.CronSchedule.<init>(CronSchedule.java:56) ~[db-scheduler-10.3.jar:na]
at com.github.kagkarlsson.scheduler.task.schedule.Schedules.cron(Schedules.java:39) ~[db-scheduler-10.3.jar:na]
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Spring Cron scheduler “disable pattern” - Stack Overflow
As of Spring 5.1.0 the @Scheduled annotation can accept "-" as the cron expression to disable the cron trigger. Per the Javadocs:.
Read more >Make it possible to disable Scheduled job via cron expression ...
Disable all job executions using a flag (to prevent someone adding @EnableScheduling somewhere to enable job scheduling that's supposed to ...
Read more >Conditionally Enable Scheduled Jobs in Spring - Baeldung
The simplest way to conditionally enable a Spring scheduled job is to use ... the job is disabled by default (using the special...
Read more >New in Spring 5.3: Improved Cron Expressions
Using the java.time APIs let us introduce several new features that put Spring's support for cron expressions on an equal footing with other ......
Read more >Scheduler Reference Guide - Quarkus
If you wish to disable a specific scheduled method, you can set its cron expression to "off" or "disabled" . application.properties. myMethod.cron.expr=disabled.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@kagkarlsson tested and confirmed it works, thanks very much
Hoping this is solved with #286. Does that implementation work for you?