How cron Scheduled tasks are executed every 30 seconds

Source: Internet
Author: User
Tags current time sleep

<cron job, how do I make a script run in half a minute? >

Cron is not going to make it. But can be implemented with the help of the sleep command.

Workaround:

Two scripts

A normal, an increase in SLEEP30

Crontab setting starts at the same time

Sleep in some shells (such as bash in Linux) to support sleeping (minutes, hours)

Sleep can be used to delay the current action for a period of time

"Sleep parameter Description:"

--HELP: Display auxiliary messages

--version: Display version number

Number: Length of time, followed by S, M, H or D

Where S is the second, M is minutes, H is the hour, D is the number of days

Delay 1 minutes after displaying the current time, and then display the time again:

Date;sleep 1m;date

Sleep 1 sleeps 1 seconds

sleep 1s 1 seconds

Sleep 1m 1 min.

Sleeping 1h sleep 1 hours

Let one of the scripts sleep for 30 seconds, and the other to run correctly

(For example):

A.sh is your script.

Write a b.sh script again

The contents are as follows:

!#/bin/bash

Sleep 30

a.sh

Then add both scripts to the cron and set the same starting condition (minutes are *)

* * * * * */path/a.sh; /Path/b.sh

If you perform every 10 seconds, add the following in b.sh:

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.