In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
First, write Shell script crontab.sh
#! / bin/bash step=1 # interval 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
Second, crontab-e enter the following statement, and then: wq save exit
# m h dom mon dow command * / home/www/php/crontab/crontab.sh
Implementation of linux second-level timing task
Train of thought:
Linux itself does not support second-level timing. To implement it, you can run a script regularly (for example, once per minute). The content of this script is actually an endless loop to execute code, that is, to execute all the time.
Note: if a timed program consumes too much time at a time, for example, if you don't play for 1 second, you need to seelp, that is, let the script sleep for a while during the endless loop.
The following shows a second-level scheduled task of a shell script:
1.crontab-e executes inviteFriend.sh scripts every minute
Run in # 2 seconds-invite friends 3.0
* / webservice/crontab/inviteFriend.sh
Change 2.cd / webservice/crontab/ to vim inviteFriend.sh under the directory
Write the following:
#! / bin/bashstep=2 # interval 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 $stepdoneexit 0
Wq save exit
Note: authorize the timed script after saving
Chmod 777 filename
Summary
The above is the Linux Crontab Shell script introduced by the editor to achieve a second-level timing task. I hope it will be helpful to you. If you have any questions, you are welcome to leave a message and the editor will reply to you in time!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.