PHP 创建所有者为 99 的文件夹
我有一个脚本(作为 cron 运行),它在服务器上创建一个名为 images
的新文件夹,并将图像从根文件夹移动到这个新文件夹。稍后,另一个函数将从这些图像创建缩略图,并将它们放入同一文件夹内另一个名为 thumbs
的新文件夹中。
但是,只有当父级 images
文件夹的所有者由于某种奇怪的原因设置为 99 时,此功能才会起作用。该文件夹将用户作为其默认所有者。
如何获取脚本来创建所有者设置为 99 的文件夹?或者 PHP 脚本无法对以用户为所有者的文件进行 chmod 操作,这可能是什么原因?
I have a script (run as a cron) that creates a new folder called images
on a server and moves images from the root folder to this new folder. Later another function will create thumbnails from these images and places these into another new folder named thumbs
inside that same folder.
However, this function will only work if the parenting images
folder has the owner set to 99 for some strange reason. The folder gets the user as its default owner.
How can I get the script to create a folder with the owner set to 99? Or what could be the reason that the PHP script has no power of chmod-ing files that have the user as the owner?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
cron 作业以
nobody
(UID 99) 身份运行,因此用户必须具有适当的权限。如果您不想更改权限,则需要以其他用户身份运行 cron 作业。The cron job is running as
nobody
(UID 99), so that user must have the appropriate permissions. You will need to have the cron job run as a different user if you don't want to change the permissions.显然,这取决于 php 脚本在 cronjob 中的运行方式来确定哪个所有者将被设置为新创建的文件的默认所有者。
首先我使用:
但这创建了新文件夹,其所有者设置为“用户名”。
而是使用curl:
允许创建新文件/文件夹,并将所有者设置为
nobody
(UID 99),这又允许下一个脚本在此文件夹中创建新文件夹/文件,没有问题。Apparently it depends on how the php script was run in the cronjob to determine which owner will be set as the default on newly created files.
First I used:
But this created new folders with the owner set to the 'username'.
Instead using curl:
Allowed the new files/folders to be created with the owner set to
nobody
(UID 99) which in its turn allowed the next script to create new folders/files inside this folder without a problem.