Why can't crontab-e execute fwrite to write files? Collapsed. Function & nbsp; Write_FileFun_new ($ filename, $ filedir, & nbsp; $ htmldata & nbsp ;=& nbsp; '') & nbsp; {if (! Is_dir ($ filedir) Why can't crontab-e execute fwrite to write files? Collapsed.
function Write_FileFun_new($filename,$filedir, $htmldata = '') {
if(!is_dir($filedir)) {
mkdir($filedir, 0777);
}
$htmlfile = $filedir.$filename;
if($fp = fopen($htmlfile, 'wbt')) {
fwrite($fp,$htmldata);
fclose($fp);
} else {
echo "
Can not write to files, please check directory $htmldir.
";
exit;
}
}
$testnum_temp="
";
Write_FileFun_new("test.php","inc/", $testnum_temp);
Running pages in a browser is normally written,
In crontab-e, the scheduled execution is performed once per minute without writing files. crontab-e is normal and can be executed once per minute.
Why is this? it's just a little worse. if all other programs are running normally, this cannot be written. Why?
------ Solution --------------------
Inc/is relative path
First, find out who it is.
------ Solution --------------------
Check the log. Is there any warning information?
------ Solution --------------------
Run the commands in crontab directly on the command line to see what the response is.
------ Solution --------------------
Write a sh file and handle the permissions. call/usr/bin/php/var/www/html/write. php in this file and use the root identity in crontab ..