Forum Moderators: coopster
$year = date('Y');
$month = date('m');
$dir = dirname(__FILE__)."/";
$log_dir = $dir."logs/".$year."/".$month;
if (!is_dir($log_dir)) {
mkdir($log_dir, '0777');
}
$log_file = $log_dir."/log_".date("Y_m_d").".txt";
The message I'm receiving (edited for confidentiality):
Warning: mkdir(/path/to/logs/2005/08): No such file or directory in /path/to/wksht_cron2.php on line 36
Warning: mkdir(): SAFE MODE Restriction in effect. The script whose uid is 1047 is not allowed to access /webdocs/acme/public_html/admin/worksheets/logs/2005 owned by uid 65534 in /webdocs/acme/public_html/admin/worksheets/mkdir.php on line 33
Here's the code in mkdir.php ...it is a test script.
$year = date('Y');
$month = date('m');
$dir = dirname(__FILE__)."/";
$year_dir = $dir."logs/".$year."/" ;
$month_dir = $year_dir.$month."/";
if(!is_dir($year_dir)) {
mkdir($year_dir);
}
if (!is_dir($month_dir)) {
mkdir($month_dir);
}$log_dir = $dir."logs/".$year."/".$month;
$log_file = $log_dir."/log_".date("Y_m_d").".txt";
is cron calling your script directly or is cron telling the webserver to run the script? If cron is running the script through the webserver, then you should change the implementation of calling the script so that the script is called by cron directly, thereby having the script run by user root.
...this is beyond my knowledge level of php. I wrote the script and told my hosting company I want it to run on the hour. That is all I know. However, I have encountered "uid" error messages.
I think for now, I will just manually create the 'month' directories... then when I have more time, move the logging to mysql for more flexibility. ....Thankyou for the assistance.