Home > Backend Development > PHP Tutorial > How to execute PHP program regularly with crontab under Linux

How to execute PHP program regularly with crontab under Linux

WBOY
Release: 2016-07-25 08:59:19
Original
1021 people have browsed it
This article introduces how to use crontab to execute PHP programs regularly in Linux systems. Friends in need can refer to it.

How to use Crontab to execute PHP regularly in Linux. The implementation steps are as follows:

1. Use crontab -e to edit scheduled tasks The content is:

xx:xx:xx executes a hello.php file

2. The php file must be in the first line of the file, plus the interpreter path (similar to bash or perl)

#!/usr/local/bin/php

Note: The execution of PHP requires the support of Apache, the execution of shell script requires the support of Linux, and Linux supports the function of running a certain program regularly. Then, execute it directly in /etc/crontab, as follows:

*/5 * * * * root /root/hello.php

The previous method was to first execute a shell program in crontab, and then let the shell program run the PHP program. This is actually quite inefficient; Instead, add the php path directly to /etc/crontab, such as

*/5 * * * * root php hello.php

, can also be executed correctly;



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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template