[英]Delaying cron tasks
On my server I can run cron tasks every 5 minutes.在我的服务器上,我可以每 5 分钟运行一次 cron 任务。 I have many clients (over 100).
我有很多客户(超过 100 个)。 In my cron task I send ping to every clients' subdomain to run it's own cron tasks.
在我的 cron 任务中,我向每个客户的子域发送 ping 以运行它自己的 cron 任务。 I don't wait for response.
我不等待回应。
Problem is that I send ping in foreach
loop and therefor server recieves many request in a single second.问题是我在
foreach
循环中发送 ping,因此服务器在一秒钟内收到许多请求。
Is there a way to delay/randomize those requests?有没有办法延迟/随机化这些请求? I knot there is a
sleep
function but it blocks server and minimum value is 1 second.我知道有一个
sleep
function 但它阻塞了服务器,最小值是 1 秒。
Add a usleep
call inside the loop, to add a little pause between each ping.在循环内添加一个
usleep
调用,在每次 ping 之间添加一点暂停。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.