php fopen ftp_get changing owner/group - sometimes - why?
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 开发者_StackOverflow中文版them? When I tell them my owner/group are wrong, they totally reset my entire ftp directory - permissions,owner, etc. which is a pain.
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:
- You can ask your webhosting provider to fix these things.
- 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.
精彩评论