Home >Backend Development >PHP Tutorial >PHP scheduled execution (windows and linux)

PHP scheduled execution (windows and linux)

WBOY
WBOYOriginal
2016-07-25 08:58:231307browse
This article introduces how to configure PHP scheduled execution in Windows or Linux. Friends in need can refer to it.

1. Under windows

<?php
//关掉浏览器,PHP脚本继续执行
ignore_user_abort();
// 可以让程序无限制的执行下去
set_time_limit(0);
while(true) {
    /*
    *存放要执行的代码
    */
   //等待30秒后再运行
    sleep(30);
}
?>

Note: If you don't want to run without restrictions, you may need to modify it. In addition, apache will not continue to run after restarting or shutting down, and you need to run it again to start the program. 2. You can use cron under Linux. For tutorials and usage of cron in Linux, you can refer to the following articles: How to automatically execute scheduled tasks with crontab in Linux How to execute PHP program regularly with crontab under Linux crontab study notes Learn the crontab command to set up scheduled tasks in Linux crontab command format and examples Linux scheduled task setting crontab learning Good crontab tutorial



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