Spring @Scheduled Usage

Source: Internet
Author: User

@Scheduled (cron = "0 5 * * *?")

 /**   * Annotation that marks a method to be Scheduled. Exactly one of the * <CODE>CRON</CODE>, <code>fixeddelay</code>, or <code>fixedrate</ code> * attributes must be provided. * * <p>the Annotated method must expect no arguments and has a * <code>void</code> return type. * * <p>processing of {  @code    @link   Scheduledannotationbeanpostprocessor}. This can is * do manually or, more conveniently, through the {  @code   <task:annotation-driven/>} * element or @{  @link   enablescheduling} annotation. *

Try with: @Scheduled (cron= "0 1 1 * *?"Here is Some example pattern found on spring forum:* "0 0 * * * *" =The top of every hour of every day.* "*/10 * * * * *" =every ten seconds.* "0 0 8-10 * * *" = 8, 9 and ten o ' clock of every day.* "0 0/30 8-10 * * *" = 8:00am, 8:30am, 9:00am, 9:30am and ten o ' clock every Day.* "0 0 9-17 * * mon-fri" = on the Hour nine-to-Five weekdays* "0 0 0 25 12?" =every Christmas day at Midnightcron expression was represented by six fields:second, minute, hour, day of month, month , day (s) of week (*) means match any*/x means "every X"? ("No specific value")-useful when you need to specify something in one of the the the and the the in which the character are allow Ed, but isn't the other. For example,ifI want my trigger to fire in a particular day of the month (say, the 10th), and But don ' t care what's Day of the week that Happe NS to IS, I would put "ten" in the Day-of-month field, and "?" in the Day-of-week field.ps:in order to do it works, remember to enable it in your application context:http://docs.spring.io/autorepo/docs/spring-framework/current/spring-framework-reference/html/scheduling.html# Scheduling-annotation-support



Spring @Scheduled Usage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.