Home > php教程 > php手册 > On planning tasks under linux

On planning tasks under linux

WBOY
Release: 2016-09-30 09:22:54
Original
1479 people have browsed it

On the function of automatically receiving goods and automatically evaluating orders after planned tasks are completed under Linux!
Friends, when you are doing program development, have you ever worried about implementing a shopping mall website or a small program to automatically execute a certain method?

Today Simengphp brings you this solution. Of course, there are many ways to achieve this, and today I will explain to you how to configure crontab under Linux! Okay, now I’m going to teach you how to perform this operation!

First of all, I want to explain to you that the editor is explaining to you how to implement this operation under Linux. As for Windows, I can also explain it to you later!

(1) We need to use the command yum install -y vixie-cron to install the scheduled task service. Friends can use crontab -e to check whether the server has this service installed before installation!

(2) After installation, we can use crontab -e to add our scheduled tasks. I will write some small examples for you:

*/1 * * * * /usr/bin/curl -o temp.txt http://www.baidu.com/index.php/Api/Contab/offeredCoupon

Execute the offeredCoupon method below in the following Api group every minute

30 21 * * * /usr/bin/curl -o temp.txt http://www.baidu.com/index.php/Api/Contab/offeredCoupon

The above example indicates that the offeredCoupon method below the following Api group is executed at 21:30 every night

45 4 1,10,22 * */usr/bin/curl -o temp.txt http://www.baidu.com/index.php/Api/Contab/offeredCoupon

The above example indicates that the offeredCoupon method below the following Api group is executed at 4:45 on the 1st, 10th, and 22nd of each month

10 1 * * 6,0 /usr/bin/curl -o temp.txt http://www.baidu.com/index.php/Api/Contab/offeredCoupon

The above example indicates that the offeredCoupon method under the following Api group is executed at 1:10 every Saturday and Sunday

Note (the following is an explanation of the above):

*  * * * * command

Hours, Days, Months, Weeks, Commands

Column 1 represents minutes 1 to 59. Each minute is represented by * or */1

Column 2 represents hours 1 to 23 (0 represents 0 o'clock)

Column 3 represents dates 1 to 31

Column 4 represents months 1 to 12

The 5th column identifies the day of the week from 0 to 6 (0 means Sunday)

Column 6 Command to run

(3) After editing the file, press the ESC key, then (:wq) save and exit

(4) service crond restart restarts scheduled tasks

The above is the configuration method of Linux scheduled tasks. Of course, in order to see the intuitive effect, we can first use the PHP function file_put_contents("1.txt", "Linux scheduled task test"); to test whether our method is Executed!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template