question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for disabled cron expression "-"

See original GitHub issue

According 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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
donalmurtaghcommented, May 30, 2022

@kagkarlsson tested and confirmed it works, thanks very much

1reaction
kagkarlssoncommented, May 18, 2022

Hoping this is solved with #286. Does that implementation work for you?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found