Skip to content

Support one off scheduled tasks #23899

Closed as not planned
Closed as not planned
@behrangsa

Description

@behrangsa

Sometimes I want to have a task that runs 1M after the app starts as well as once a day at 1AM.

Right now, there doesn't seem to be an option using @Scheduled to do this.

A workaround is to annotate the method like this:

@Scheduled(cron = "...")
@Scheduled(initialDelayString = "PT1M", fixedDelay = Long.MAX_VALUE)
public void doSomething() {
}

It would be nice if @Scheduled had an attribute such as runOnce=true|false and/or maxRuns=integer to control how many times a scheduled job is allowed to run.

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions