crontab - PHP CLI 无限执行问题

WBOY
Release: 2016-06-06 20:25:41
Original
1333 people have browsed it

我想弄一个队列 异步写入数据的程序

假设用CRONTAB的方式则有时间差异(如1分钟一次)

假设用do{} whlie(1)

的方式则会大量占用CPU 有什么方法,即可以无限执行,又能不占用CPU!

回复内容:

我想弄一个队列 异步写入数据的程序

假设用CRONTAB的方式则有时间差异(如1分钟一次)

假设用do{} whlie(1)

的方式则会大量占用CPU 有什么方法,即可以无限执行,又能不占用CPU!

1,设置:
set_time_limit(0)
2.设置主进程
pcntl_wait ( int &$status [, int $options ] );等待子进程

sleep()间隔

在while(1)中做完一次任务后可以调用sleep()睡眠一段时间,睡眠期间是不占用CPU资源的.

Related labels:
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!