Several ways to perform tasks per second in Linux crontab

Source: Internet
Author: User

The first method:

1. Create a script file

The code is as follows Copy Code
Cat phplog.sh
2. Edit Script Content
#!/bin/bash
While:;d o
/home/scripts.sh 2>/dev/null &
Sleep 1
Done

Note: Do not use bash phplog.sh & the way the background runs this first time, it will be zombie.
Workaround: You can put it on a scheduled task to run it, and then delete this entry from the scheduled task. Finally, put the script in/etc/rc.local so that it can be run every time it is powered on.

The second method:

The code is as follows Copy Code

1. Create a script file
Cat phplog.sh
2. Edit Script Content
#!/bin/bash
For ((i=1;i<=20;i++));d o
/home/scripts.sh 2>/dev/null &
Sleep 1
Done
3. Edit Crontab Script
* * * * */bin/bash/home/somedir/phplog.sh * * *

The third method:

1. Edit Crontab Script

The code is as follows Copy Code
* * * * */home/scripts.sh * * *
* * * * * * Sleep 1 &&/home/scripts.sh
* * * * * * Sleep 2 &&/home/scripts.sh
* * * * * * Sleep 3 &&/home/scripts.sh
...
* * * * * * sleep &&/home/scripts.sh
* * * * * sleep &&/home/scripts.sh
* * * * * sleep &&/home/scripts.sh

Finally, a third method is recommended.

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.