My default cpanel set up runs apache as user "nobody". So when I run a php script via a browser that outputs a file, that file has ownership nobody:nobody. When I run the script from a cron job logged in as user "fred", the output files are owned by fred:fred I need both browser and cron to overwrite the same file. The issue I have is that if one "user" creates the file, the other one can't overwrite it. Please can you let me know where the fundamental problem is and a possible solution. Permissions on the files are 0775.
Many thanks, Lloyd
Try you code after changing permission of the file as 0777. But that creates a security issue as anyone can edit your file then.
I have a logic you need to implement to:
For ssh2_exec manual follow this link : http://php.net/manual/en/function.ssh2-exec.php
Hope This will solve your problem.
Ok, my solution to this was to create a crontab for user "nobody". I've got a standard cpanel installation and so went to /var/spool/cron created an entry for nobody. Ran crontab -e to edit it and install. Now the php runs as nobody in the cron job exactly the same as if through a browser. All files written belong to nobody with only rw permissions for nobody.