@Schedule annotation run every few minutes (or seconds)

前端 未结 2 856
闹比i
闹比i 2021-02-03 22:06

I would like to try to use the @Schedule annotation in the following way:

public class MyTestServlet extends HttpServlet {
    private static JcanLogger LOG = Jc         


        
2条回答
  •  孤城傲影
    2021-02-03 22:39

    Please find the following details for the scheduler configuration.

    (1) To run every 1 min

    @Schedule(hour = "*", minute = "*/1", persistent = false)
    

    (2) To run every 5 mins

    @Schedule(hour = "*", minute = "*/5", persistent = false)
    

    (3) To run every 30 seconds

    @Schedule(hour = "*", minute = "*", second = "*/30", persistent = false)
    

    (4) To run every day at 6:00 am

    @Schedule(hour = "6", minute = "0", second = "0", persistent = false)
    

    (5) To run on every Friday at 2:00 pm

    @Schedule(dayOfWeek = "Fri", hour = "14", persistent = false)
    

    (6) To run on the first day of every month at 5:00 am

    @Schedule(dayOfMonth="1", hour = "5", persistent = false)
    

    I hope this information will help you to configure the scheduler as per your requirement.

提交回复
热议问题