运行一个脚本文件我已经写了一个脚本生成一些XML,使用一个非常基本的方法对XML的结果保存到一个文件IM:PHP的 - 创建由通过cron
<?php
// start the output buffer to cache the content
ob_start();
//SOME PHP CODE HERE TO GENERATE CONTENTS ON THE FILE
$cachefile = "results.xml";
// open the cache file for writing
$fp = fopen($cachefile, 'w');
// save the contents of output buffer to the file
fwrite($fp, ob_get_contents());
// close the file
fclose($fp);
// Send the output to the browser
ob_end_flush();
当我手动转到脚本运行的服务器上包含脚本的文件的URL,并创建该文件。
但是,当我尝试将其作为cron作业运行时,脚本将运行,并且输出将通过未保存到文件而生成。
任何想法为什么?
你检查过文件权限吗? – 2012-04-07 00:06:14
你应该看看你的错误日志,可能会有一些有趣的错误消息。 – Stony 2012-04-07 00:07:33
你的日志中是否有错误?我假设你正在cli上执行脚本,而不是通过cron请求你的服务器。你是否可能从另一个位置执行它? – csupnig 2012-04-07 00:08:41