Is there any technology that allows the server to call a program every period of time
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>
<code>*/2 * * * * /path/to/your/php /path/to/your/php/script >> /tmp/oxox.log</code>
crontab