Skip to content

spring boot scheduling #307

@uniquejava

Description

@uniquejava

Spring cron expression for every day 1:01:am

show me the java code

@EnableScheduling
@SpringBootApplication

public class AwesomeApplication {
}


@Service
@Slf4j
public class ScheduleService {
    @Autowired
    private EventMapper eventMapper;

    // second, minute, hour, day of month, month, day(s) of week
    @Scheduled(cron = "0 * * * * *")
    void checkEvents() {
       ...

    }

}

important note

zone matters in some cases

Scheduled(cron="0 1 1 * * *", zone="Europe/Istanbul")
public void doScheduledWork() {
    //complete scheduled work
}

cron format

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions