Two schemes of implementing second-level scheduled tasks under Linux

Source: Internet
Author: User

Two scenarios for implementing second-level scheduled tasks under Linux (Crontab runs per second):

The first scenario, of course, is to write a script that runs in the background all the time, and then loop through sleep for a while.

While True;d o

Command

Sleep XX//interval of seconds

Done

The second option is to use crontab.

We all know that the granularity of crontab is up to the minute, but we can still run it in a few seconds by doing it in a flexible way.

The following methods are executed every 20 seconds

Crontab-e
* * * * * */bin/date
* * * * * * sleep 20; /bin/date
* * * * * * sleep 40; /bin/date

Description: Need to change/bin/date to your command

This approach to deal with the dozens of-second scheduled task is OK, if run every 1 seconds to add 60 records ... If you run it every second or plan one.

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.