The server executes an automated program

WBOY
Release: 2016-07-06 13:51:34
Original
1208 people have browsed it

Is there any technology that allows the server to call a program every period of time

Reply content:

Is there any technology that allows the server to call a program every period of time

It depends on what program and server you have.
Use crontab for minute-level scheduled tasks on Linux servers, but you need to write your own scripts for second-level tasks.
Windows can have scheduled tasks or write some programs (Java, .NET) to do scheduling
To put it bluntly, it is scheduling

Use crontab

PHP has a method that can ignore the user closing the window and run for a long time

<code><?php
while(1) {
    //这里写你的业务逻辑代码.
    //注意!如果用到数据库,每次循环都要显式关闭MySQL连接.
    //同时要注意对可能的连接失败,操作失败进行处理.
    //另外记得用unset释放掉不再使用的变量,避免内存泄漏.
    $str = file_get_contents('http://php.net/images/logo.php');
    unset($str);
    sleep(2); //每隔2秒
}</code>
Copy after login

<code>*/2 * * * *  /path/to/your/php   /path/to/your/php/script >> /tmp/oxox.log</code>
Copy after login

crontab

Related labels:
php
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