954,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

PHP cron permission

Hi,

I am setting up a cron using php.

I have a file which I want to update by doing file_put_contents() on it via cron and via web browser (manual).

everything via web brower works fine, but cron gives a "permission denied".

I am overwriting the file each time it gets updated.

How can I resolve the permission issue?

Thanks in advance.

jakesee
Junior Poster
130 posts since Jul 2008
Reputation Points: 21
Solved Threads: 5
 

Did you set your permissions on the file to 0777?

timmah
Newbie Poster
5 posts since May 2009
Reputation Points: 10
Solved Threads: 1
 
Did you set your permissions on the file to 0777?

I do not know how to set it programmatically.

Setting it via FTP is useless because each update rewrites the permission.

by "update" I mean running file_put_contents() on the file using the web brower. with cron, nothing works because of the permission problem.

I think I understand the reason being each time file_put_contents() is used, the file is re-created and the owner changes.

currently what I do is to unlink() the file, and then file_put_contents() again. But I think this is quite ridiculous because I can unlink() but cannot overwrite? So, I would like to learn how to do it the proper way with permissions. Any advice?

Thanks.

jakesee
Junior Poster
130 posts since Jul 2008
Reputation Points: 21
Solved Threads: 5
 

What you should do is set the file inside a folder, set the permissions of the folder, and all content to 0777.
That way, every file that gets sent to that folder will have the correct permission.

timmah
Newbie Poster
5 posts since May 2009
Reputation Points: 10
Solved Threads: 1
 
What you should do is set the file inside a folder, set the permissions of the folder, and all content to 0777. That way, every file that gets sent to that folder will have the correct permission.

Like I said, everytime the update takes place, the permission resets. So it doesn't work out. =(

jakesee
Junior Poster
130 posts since Jul 2008
Reputation Points: 21
Solved Threads: 5
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You