View Full Version : Problem With FWrite Within A Cronjob

10-25-2009, 05:19 PM
I have the following file:

$ccyymmdd = date("Y - m - d (G,i)");
$file = fopen("dbbackups/".$ccyymmdd.".php","w");
// Write stuff here

When run from my browser it works fine. When I run from a cron job my Cron Daemon sends me a report:

Warning: fopen(dbbackups/2009 - 10 - 25 (11,10).php): failed to open stream: No such file or directory in /home/xxxxx/public_html/dbbackupcron.php on line 7

My Cron:
/usr/local/bin/php -q /home/xxxxxxx/public_html/dbbackupcron.php

Anyone know a work around for this? Perhaps using CURL instead of PHP?

10-25-2009, 05:52 PM
You may need to use the absolute path to refer that file.

10-25-2009, 06:21 PM
Got it working with CURL in the end, thanks for your help