开发者

PHP Timeouts and FTP function

开发者 https://www.devze.com 2023-01-07 23:50 出处:网络
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, b开发者_Python百科acking up one file pe

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, b开发者_Python百科acking 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.


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.


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');


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消