问题描述
我有一个php脚本,可以采取任何从2到10分钟执行。它从网络上获取信息,所以它的时间取决于很多其他东西谈话的速度。
我用于每15分钟在cron上运行脚本,但是有时只需要2分钟即可运行。
所以我想知道我是否能以某种方式使它永远运行 - 一旦完成任务,它会再次运行?
看起来像你正在使用cron工作问题。我会把你的脚本变成一个守护进程,这样它可以永远运行,而不必担心重叠或完成太快。
这里是一个教程如何做。 p>
I have a php script that can take anything from 2 to 10 minutes to execute. It fetches info from around the web so its time depends on how fast lots of other things are talking.
I used to run the script on a cron every 15 minutes, but sometimes it only takes 2 minutes to run.
So I wondered if I can somehow make it run perpetually - setting itself going again as soon as it finishes its task? That way, however long it takes, it will always start agaiun straight away.
Seems like you're running into cron job issues. I would instead turn your script into a daemon, that way it can run perpetually without fear of overlaps or finishing too fast.
Here's a tutorial how to do it.
http://kevin.vanzonneveld.net/techblog/article/create_daemons_in_php/
这篇关于php脚本,当它完成时调用自身 - 无限期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!