1. Write Shell script crontab.sh #!/bin/bash step=1 #The number of seconds between steps cannot be greater than 60 for (( i = 0; i < 60; i=(i+step) )); do $(php '/home/www/php/crontab/crontab.php') sleep $step done exit 0 2. Enter the following statement in crontab -e, then press :wq to save and exit # mh dom monitor command * * * * * /home/www/php/crontab/crontab.sh Linux second-level scheduled task implementation Ideas: Linux itself does not support second-level timing. To achieve this, you can run a script at a fixed time (for example, once every minute). The content of this script is actually an infinite loop execution code, that is, it keeps executing. Note: If the time taken for a scheduled program to execute is too long, for example, it takes more than 1 second to execute, you need to seelp, that is, let the script sleep for a while in the infinite loop. The following demonstrates a shell script's second-level timing task: 1.crontab -e executes the inviteFriend.sh script every minute #2 seconds to run - Invite friends 3.0 * * * * * /webservice/crontab/inviteFriend.sh 2.cd /webservice/crontab/ Switch to the directory vim inviteFriend.sh Write the following content: #!/bin/bash step=2 #The number of seconds between steps cannot be greater than 60 for (( i = 0; i < 60; i=(i+step) )); do #$(php '/home/php/crontab/tolog.php') curl -I http://******.com/InviteFriends/sendInviteFriendCoupon sleep $step done exit 0 wqSave and exit Note: After saving, you need to authorize the script. chmod 777 filename Summarize The above is the method that I introduced to you to use Linux Crontab Shell script to implement second-level scheduled tasks. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time! You may also be interested in:
|
<<: Mysql keeps the existing content and adds content later
>>: js to write the carousel effect
Overview Nginx can use variables to simplify conf...
Preface Recently, I encountered a requirement at ...
Why? The simplest way to put it is that pixels are...
1. Promise description Promise is a standard buil...
I have never been able to figure out whether the ...
I'm currently working on my own small program...
vue+el-upload multiple files dynamic upload, for ...
Browser compatibility is nothing more than style ...
Table of contents One-way data flow explanation V...
If prompted to enter a key, select [I don’t have ...
After pressing Enter on the webpage, the form is a...
Error message: Job for mysqld.service failed beca...
Introduction In the previous article, we installe...
Transaction A transaction is a basic unit of busi...
1. Rendering 2. Source code HTML < body > &...