In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Recently, a project needs to execute the controller every minute on the server. It can be executed with scheduled tasks from the Internet, and I have taken a lot of detours. Linux is a little simple, because the test server is linux, and the customer is using windows server 2016, so both methods are used.
Briefly explain my needs, I need the server to execute a URL regularly, because I have written the method in the controller, the entire URL uses the tp framework, so a lot of code written on the Internet can be imitated, but can not be used directly.
1 、 linux
Crond is a command that linux uses to execute the program on a regular basis. Specific usage can be done by Baidu or other detailed documents. There is no detailed explanation here, only how to do a scheduled task through crond.
There are 2 ways to add tasks:
1. Type: crontab-e on the command line and then add the corresponding task, and wq saves and exits.
two。 Edit the / etc/crontab file directly, that is, vi / etc/crontab, and add the appropriate tasks.
Such as:
* sleep 1; / usr/bin/curl http://www.sxfewwa.com/Home/JPush/autoConfirm
Execute this link in curl every other minute
Order for hours, days, months and weeks
0-59 0-23 1-31 11-120-6 command (value range: 0 indicates that a typical Sunday row corresponds to a task)
2 、 windows server
The first step is to write your own method, the php file, and test it with the following test.php code:
If you are using thinkphp, like me, the method in Controller is the same as the others, of course, you can add a
Function test () {
$fp = fopen ("test.txt", "a +")
Fwrite ($fp, date ("Y-m-d H:i:s"). "successful!\ n")
Fclose ($fp)
}
Step 2: write the bat file
Set link= http://www.sxfewwa.com/Home/JPush/autoConfirm
Start iexplore "link%"
Ping-n 80 127.1 > nul
Taskkill / f / im "iexplore.exe"
3. Windows is a little more troublesome. You need to create a task in "Management tools"-> "schedule tasks".
Process can be viewed (http://blog.csdn.net/woshixuye/article/details/18050769) there are many similar articles on the Internet.
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
Switch-1# show interface brief
© 2024 shulou.com SLNews company. All rights reserved.