Skip to content

spring boot scheduling #307

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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