PHP and cron jobs

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hey all

I help out at a gaming website, where we play BF2 and track player  
stats/give them awards etc. I've got a whole backend and everything  
works exactly as I need... except for when I need to update the awards  
via cron job. Then I'm getting a "imagepng(): Unable to open 'xxx.png'  
for writing in XXX". All the paths are correct as it loads other images  
as part of the process, and I belive it's a permission issue. The files  
are in a 777 folder and each file has the permission of 644 (User 65534,  
grou 65534) - what am I doing wrong?

(BTW tried different permissions, and if I delete the file the cron job  
creates it, but then you can't access it via a http request)

Many thanks

Re: PHP and cron jobs

Matthew Augier wrote:
Quoted text here. Click to load it

As I understand it:

cron runs as the effective user id of the name of the crontab file.
e.g. if you have a crontab file named 'foo', then crontab will run as  
the effective user 'foo'.

I say 'effective user' since if there are two accounts, say 'foo' and  
'bar', and both have a userid of 1234 and 'bar' is located ahead of  
'foo' in the /etc/passwd file, then cron will run as 'bar' even though  
the crontab file is named 'foo'.

That aside, I think your issue is that the effective user cron is  
running your job as is not able to write the file. (i.e. it is not  
running as user 65534).

1. run the cron job as user 65534.
2. run the cron job and sudo to userid 65534
3. open the permissions on xxx.png to 666


Re: PHP and cron jobs

Thanks David, I deleted all the files and changed teh ribbon creation  
routine to chmod the file when it was created as 666, this looks like it has  

As this is a shared host running the cron as root or sudo (new to me but  
from what I can tell changes me as a used to root with passwrod) are two  
options not open.

Quoted text here. Click to load it

Site Timeline