cron线看起来像:
*/1 * * * * /usr/bin/php /path/to/CRON.php > /path/to/log/CRON_LOG.txt 2> /dev/nullCRON.php
require_once 'config.php';
define('CRON', dirname(dirname(__FILE__)));
$parts = explode("/",__FILE__);
$ThisFile = $parts[count($parts) - 1];
chdir(substr(__FILE__,0,(strlen(__FILE__) - strlen($ThisFile))));
unset($parts);
unset($ThisFile);
$CRON_OUTPUT = "STARTING CRON @ ".date("m-d-Y H:i:s")."\r\n";
$CRON_OUTPUT .= CleanLog() . "\r\n";
$CRON_OUTPUT .= "\r\n";
echo $CRON_OUTPUT;
$fh = fopen(''.CRON.'/log/CRON_LOG.txt', 'a');
fwrite($fh, $CRON_OUTPUT);
fclose($fh);
die();
?>CleanLog功能:
global $db;
$resp = '';
$db->query('SQL');
$resp = 'Deleted '.$db->rows_affected.' entries from table';
return $resp;在文件中,只有这两行显示和功能的时间,因为我可以看到执行两次:
CRON_LOG.txt
STARTING CRON @ 02-26-2012 21:26:01
Deleted 0 entries from table
STARTING CRON @ 02-26-2012 21:26:01
Deleted 0 entries from table它有什么问题,为什么它只产生这些行和文件没有更新(文件只有日期/时间变化,没有更多,它应该添加更多的行,甚至文件大小应该增长)?