Home  >  Article  >  Backend Development  >  Realize scheduled execution of php scripts under linux, linux execution of php scripts_PHP tutorial

Realize scheduled execution of php scripts under linux, linux execution of php scripts_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:06:36672browse

Realize scheduled execution of php scripts under linux, and execute php scripts under linux

Enter commands in linux

Copy code The code is as follows:

crontab -e

Then use the vim command to edit the open file and enter

Copy code The code is as follows:

0 * * * * /usr/bin/php -f /home/userxxx/update.php

Save, exit, okay, now the system will automatically execute the update.php script at every 0 o'clock. In the script, you can write functions such as database execution and automatic email sending.

Note: Directly writing 0 * * * * php -f /home/userxxx/update.php will not work.

In addition, the format of cronjob is:

MIN HOUR DOM MON DOW CMD

Field Description Allowed Value
MIN Minute field 0 to 59
HOUR Hour field 0 to 23
DOM Day of Month 1-31
MON Month field 1-12
DOW Day Of Week 0-6 (0 means Sunday)
CMD Command Any command to be executed.

Use (-) to delimit the range

For example: 0 0-6 * * * command means executing command

from 0-6 o'clock every day

Use (,) to enumerate time

For example: 0,15,30,45 * * * * command means that command will be executed at 0 minutes, 15 minutes, 45 minutes and 30 minutes of each hour

Use (/) to specify the interval

For example: * */4 * * * command means executing command

every four hours

Combined usage

0-10/2 * * * * command means executing command

every 2 minutes in the first 10 minutes

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/958258.htmlTechArticleLinux implements scheduled execution of php scripts. Linux executes php scripts. Enter the command in linux and copy the code. The code is as follows: crontab - e Then use the vim command to edit the open file and enter copy...
Statement:
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