更新从 cron 调用的 PHP 文件
我有一个在服务器中运行的脚本,它正在调用类中的函数。这是一个很长的函数,有一个 foreach 导入数据,已经运行了几个小时,估计还会运行几个小时。
现在我被要求对此文件进行更新(在另一个函数上)。我的问题是,如果我在服务器上更新这个,会影响当前脚本的运行吗?这是如何工作的,服务器缓存了这些指令并且新文件不会影响它们?或者会吗?我很困惑!
I have a script running in a server, which is calling a function in a class. This is a long function, with a foreach importing data, which has been running for a couple of hours and it is estimated to keep running for a couple more.
Now I was asked to do an update on this file (on another function). My question is, if I update this on the server, will that affect the running of the current script? How does this work, the server has those instructions cached and the new file won't affect them? Or it will? I'm confused!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
除非脚本通过包含 no 来回忆自己,否则不会更新。第一次调用脚本时,它位于内存中。但是,如果您有一些递归性并且它重新包含自身,那么是的,它将是更新版本。
Unless the script recalls him self with a include no it will not be updated. The first time the script is invoked it is in memory. But if you have some recursiveness and it reincludes itself then yes it will be the updated version.
正如@Iznogood 所写,你无法知道脚本是否会被重新加载,所以为什么要冒险呢?
您可以使用类似以下内容仅在执行完成后运行更新:
灵感来源:https://stackoverflow.com/a/7485831< /a>
As @Iznogood wrote you can't know if script will be reloaded, so why to take a risk?
You can use something like following to run the update only after the execution is finished:
Inspired by: https://stackoverflow.com/a/7485831