php fopen ftp_get 更改所有者/组 - 有时 - 为什么?

发布于 2024-09-18 06:11:07 字数 572 浏览 6 评论 0原文

在我的 php 主机上,我有一个由 cron 作业运行的脚本,该作业从远程 ftp 服务器打开/覆盖文件。它在大多数情况下都有效,但我发现当它最初创建文件时,所有者/组是“736/736”,但在某些时候所有者和组更改为“99/99”。问题是我开始遇到权限问题 - 这是代码:

$local = fopen("/mypath/myfile.txt","w");
$result = ftp_fget($conn_id, $local,"remotepath/remotefile.txt", FTP_BINARY);
fclose($local);

我正在使用相同的代码来获取一堆文件。 并非所有文件都会发生这种情况。除了“读”类型的 fopen(“r”)之外,这个原始文件再也不会被触及。

我不认为这是 ftp_fget,因为我有一个不同的脚本,也由 cron 运行,通过 fopen“w”创建文本文件,其中一些文件也是所有者“99/99”。

有什么想法吗?这可能是 ISP 方面的配置问题吗?如果是这样,我该怎么告诉他们?当我告诉他们我的所有者/组是错误的时,他们完全重置了我的整个 ftp 目录 - 权限、所有者等,这很痛苦。

On my php host, I have a script that is run by a cron job that opens/overwrites a file from a remote ftp server. It works most of the time, but I am finding that when it initially creates the file, the owner/group are "736/736", but at some point the owner and group change to "99/99". Problem is I start running in to permissions issues - here is the code:

$local = fopen("/mypath/myfile.txt","w");
$result = ftp_fget($conn_id, $local,"remotepath/remotefile.txt", FTP_BINARY);
fclose($local);

I am using this same code to pull down a bunch of files.
It does not happen to all the files. This original file is never touched again, except for a 'read' type fopen ("r").

I do not think it is the ftp_fget, as I have a different script, also run by cron that creates text files via an fopen "w", and SOME of those files are also owner "99/99".

Any thoughts? Could this be a config problem on the isp's side? If so, what do I tell them? When I tell them my owner/group are wrong, they totally reset my entire ftp directory - permissions,owner, etc. which is a pain.

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

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

发布评论

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

评论(1

(り薆情海 2024-09-25 06:11:08

组 UID 99 和所有者 UID 99 是 Nobodyapache。这对于文件系统创建的所有文件夹都是相同的。因此,当 cron 作业运行时,这些文件归 apache 所有。

解决方案:

  1. 您可以要求您的网络托管提供商修复这些问题。
  2. 将所有要读/写的文件转换为 777。如果文件是 777,它通常不会尝试更改权限。然而,如果创建了新文件,它们将在 99 之前再次成为所有者。

The Group UID 99 and Owner UID 99 is Nobody or apache. This is the same for all folders created by the file system. So, when cron job runs, the files are owned by apache.

Solutions:

  1. You can ask your webhosting provider to fix these things.
  2. Convert all files that it's going to read/write to 777. If files are 777, it usually does not try to change permission. However, if new files are created, they will again be owner by 99.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文