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
Table of contents 1. Object change detection 2. Q...
Table of contents Preface Basic Usage grammar Err...
Table of contents Math Objects Common properties ...
Earlier, we used Docker to simply deploy the Spri...
The input box always displays the input history wh...
This article mainly introduces the case of Vue en...
A must-have for interviews, you will definitely u...
Preface Named slots are bound to elements using t...
Vue $http get and post request cross-domain probl...
1. Introduction Recently, I helped a friend to ma...
MySQL handles duplicate data Some MySQL tables ma...
Update: Now you can go to the MySQL official webs...
A very useful function group_concat(), the manual...
yum quick install mysql Add yum repository rpm -U...
I summarized the previous notes on installing MyS...