PHP 超时和 FTP 功能

发布于 2024-09-10 11:50:23 字数 340 浏览 1 评论 0原文

在实现我在这个服务器故障问题中描述的备份脚本时,我遇到了一些超时问题,这些问题促使我进行了优化到代码(即,每次执行脚本时备份一个文件,并尽一切努力最大限度地减少我在非常大的数据文件上计算的文件哈希的数量)。

到目前为止,这似乎已经解决了超时问题,但考虑到文件的大小,传输时间肯定比脚本超时之前分配的标准 30 秒更长。如果发生这种情况,我认为文件将因部分传输而被切断。有什么办法可以防止这种情况发生吗?

请注意,我在共享托管环境中操作,因此无法编辑 php.ini 文件。

In implementing the backup script I described in this serverfault question, I ran into some timeout issues that have prompted optimizations to the code (namely, backing up one file per execution of the script and doing everything I can to minimize the number of file-hashes I am calculating over the very large data files).

So far, that seems to have solved the timeout issue, but given the size of the files, there is certainly room for the transfer to take longer than the standard 30s allotted before a script times out. If that happens, I assume the file will simply be cut off as partially transferred. Is there any way to protect against this?

Note that I am operating on a shared-hosting environment, so editing the php.ini file is not an option.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

雄赳赳气昂昂 2024-09-17 11:50:23

如果启用,您可以调用 set_time_limit()。或者,如果您从命令行(通过 cron 或类似方式)运行 php,则最大执行时间不适用。

If it's enabled, you can call set_time_limit(). Alternatively, if you run php from the command line (via cron or similar), max execution time does not apply.

相守太难 2024-09-17 11:50:23

您可以尝试通过 shell 运行 ftp 作业吗?可能在共享主机上工作...

shell_exec('nohup ftp my-ftp-command 2> /dev/null');

Can you try running the ftp job via the shell? Might work on a shared host...

shell_exec('nohup ftp my-ftp-command 2> /dev/null');
黯然 2024-09-17 11:50:23

根据 set_time_limit(),这永远不会成为问题因为在计算超时问题的脚本执行时间时,不包括执行脚本外部活动所花费的时间。

According to set_time_limit(), this should never be an issue because time spent executing activities outside the script are not included when calculating execution time of the script for timeout issues.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文