Home > Backend Development > PHP Tutorial > Introduction to methods of scheduled execution of php

Introduction to methods of scheduled execution of php

WBOY
Release: 2016-07-25 09:10:36
Original
948 people have browsed it
  1. #!/usr/bin/php -q
  2. $file = "/var/www/".date('H').'_'.date('i'). '_'.date('s').'.txt';
  3. file_put_contents($file,date('Y-m-d'));
  4. ?>
Copy the code

Then chmod +x test .php gives test.php executable permissions.

3. Command crontab -e */1 * * * * /var/www/test.php Execute test.php every minute

4、/etc/init.d/cron restart Second way: 1. vi /etc/crontab */1 * * * * root /var/www/test.php

2. You can also remove the first line of the test.php header #!/usr/bin/php -q Then the crontab task is written as: */1 * * * * root /usr/bin/php /var/www/test.php Note: The path for php execution is relative/root. Finally, write the absolute path



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