Springcloud timed Task Configuration

Source: Internet
Author: User

write Java business code that needs to be added on top of the class declaration@Component Annotations and add @scheduled (cron = "0/5 * * * * *") on the method declaration that requires timed task execution Annotations and related parameters

Package Com.gf.test.core.schedule;import Org.joda.time.datetime;import Org.slf4j.logger;import Org.slf4j.loggerfactory;import Org.springframework.scheduling.annotation.scheduled;import org.springframework.stereotype.Component; @Componentpublic class Scheduletest {private static final Logger Logger = Log    Gerfactory.getlogger (Scheduletest.class);    @Scheduled (cron = "0/5 * * * * *?")    public void Test () {Logger.info (New DateTime (). toString ()); }}


Timed Task Instances

"0 0 12 * * ?" Daily 12 o'clock Noon trigger "0 15 10 ? * *" 10:15 "0 15 10 * * ?" 10:15 trigger "0 15 10 * * ? *" every day 10:15 "0 15 10 * * ?  2005 "2005 Years a day 10:15 trigger" 0 * 14 * * ? " Daily from 2 o'clock in the afternoon to 2:59 every minute trigger "0 0/5 14 * * ?" Every 5 minutes from 2 o'clock in the afternoon to 2:55 each day triggers "0 0/5 14,18 * * ?" Every 5 minutes from 2 o'clock in the afternoon to 2:55 and 6 to 6:55 each time the "0 0-5 14 * * ?" is triggered. Daily from 14:00 to 14:05 per minute trigger "0 10,44 14 ? 3 wed" every Wednesday 14:10 and 14:44 triggers "0 15 10 ?" in March.  * mon-fri "Every Monday, Tuesday, Wednesday, Thursday, Friday 10:15 triggers" 0 15 10 15 * ? " 10:15 of the monthly number 15th triggers "0 15 10 L * ?" 10:15 of the last day of the month triggers "0 15 10 ? * 6l" The last Friday of the month for the 10:15 trigger "0 15 10 ? *  6l 2002-2005 "2002 to 2005 of the last Friday of the month 10:15 trigger" 0 15 10 ? * 6#3 "the third Friday of 10:15 triggers" 0  0 */1 * * ? " Execute "0 0/5 * * * ?" once per hour. Executed every five minutes

Reference address:http://blog.csdn.net/tuzongxun/article/details/51576301

Springcloud timed Task Configuration

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.