Why can't crontab-e execute fwrite to write files? Collapsed

Source: Internet
Author: User
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 ..

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.