cron-job run PHP and file opening

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
LonelyProgrammer
Forum Contributor
Posts: 108
Joined: Sun Oct 12, 2003 7:10 am

cron-job run PHP and file opening

Post by LonelyProgrammer »

Hi,

I am using crontab (in cpanel) to run a php script. For some reasons, I cannot seem to open any file from within the php script (the same code works fine if I just run it straight without cron). What could be reasons? What can I do?

Thanks!
youscript
Forum Newbie
Posts: 10
Joined: Thu Sep 13, 2007 3:22 am

Re: cron-job run PHP and file opening

Post by youscript »

Maybe some problem about the path of the file,
You can display the error in your script when open the file, post the error or your code here.
LonelyProgrammer
Forum Contributor
Posts: 108
Joined: Sun Oct 12, 2003 7:10 am

Re: cron-job run PHP and file opening

Post by LonelyProgrammer »

This is the email sent by the CRON Daemon:
X-Powered-By: PHP/5.2.5
Set-Cookie: PHPSESSID=894b3895ad6900e39f90c060552ab6b5; path=/
Expires: Mon, 20 Dec 1998 01:00:00 GMT
Last-Modified: Fri, 02 May 2008 07:15:03 GMT
Cache-Control: no-cache, must-revalidate
Pragma: no-cache
Content-type: text/html

<br />
<b>Warning</b>: fopen(./log/ipnlog.txt) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: Permission denied in <b>/home/domainname/public_html/vfpp_ipn/credits/php/util/PHPLogger.php</b> on line <b>43</b><br />
Failed to obtain a handle to log file 'ipnlog.txt'<br />
<b>Warning</b>: fopen(./log/warnings_05-02-08.txt) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: Permission denied in <b>/home/domainname/public_html/vfpp_ipn/credits/php/util/PHPLogger.php</b> on line <b>50</b><br />
Failed to obtain a handle to warning log file './log/warnings_05-02-08.txt'<br />
<b>Warning</b>: fopen(./log/errors.txt) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: Permission denied in <b>/home/domainname/public_html/vfpp_ipn/credits/php/util/PHPLogger.php</b> on line <b>56</b><br />
Failed to obtain a handle to error log file './log/errors.txt'CRON job activated at :1209712503
It has failed to open a file handle - it has to be mentioned this code, if run directly without using CRON to invoke it, works. Is there any other method for me to output to a file besides fopen?
Post Reply