cron line看起来像:
*/1 * * * * /usr/bin/PHP /path/to/CRON.PHP > /path/to/log/CRON_LOG.txt 2> /dev/null
CRON.PHP
<?PHP require_once 'config.PHP'; define('CRON',dirname(dirname(__FILE__))); $parts = explode("/",__FILE__); $ThisFile = $parts[count($parts) - 1]; chdir(substr(__FILE__,(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
它有什么问题,为什么它只生成那些行并且文件没有更新(在文件中只更改日期/时间,仅此而已,它应该添加更多行,甚至文件大小应该增长)?