构建一个脚本,该脚本执行从 cron_schedule 表创建的格式化表。
我知道发布链接的常见做法,但 MagentoCommerce.com 可能不会很快消失,在这里发布代码是一个皇家 PITA。 So here's the link to a PHP script that reads cron_schedule and creates a full report. 代码见底部。进入系统配置 cron 设置并告诉它保存信息 24 小时。
您现在可以看到正在计划的所有内容以及已执行的所有内容,如以下输出示例所示。
很抱歉链接上的 MageBayvaporation,我试图将最重要的东西移到这里,但错过了这个。幸运的是,它仍在其中一个站点上运行。
<?php
/******************************************************
* Magento Log File Contents Monitor.
* Released under the Digital Damnation Copyright
* Free to do whatever the 7734 you want to do with it.
* provided without warranty or support
******************************************************/
/***********************
* Scan Magento local.xml file for connection information
* Run out of password protected scripts/ directory
***********************/
if (file_exists('../app/etc/local.xml')) {
$xml = simplexml_load_file('../app/etc/local.xml', NULL, LIBXML_NOCDATA);
$db['host'] = $xml->global->resources->default_setup->connection->host;
$db['name'] = $xml->global->resources->default_setup->connection->dbname;
$db['user'] = $xml->global->resources->default_setup->connection->username;
$db['pass'] = $xml->global->resources->default_setup->connection->password;
$db['pref'] = $xml->global->resources->db->table_prefix;
$tables = array(
'dataflow_batch_export',
'dataflow_batch_import',
'log_customer',
'log_quote',
'log_summary',
'log_summary_type',
'log_url',
'log_url_info',
'log_visitor',
'log_visitor_info',
'log_visitor_online',
'catalog_compare_item',
'report_event',
'report_compared_product_index',
'report_viewed_product_index',
'sales_flat_quote',
'sales_flat_quote_address',
'sales_flat_quote_address_item',
'sales_flat_quote_item',
'sales_flat_quote_item_option',
'sales_flat_quote_payment',
'sales_flat_quote_shipping_rate'
);
}
else {
exit('Failed to open ../app/etc/local.xml');
}
/** Get current date, time, UTC and offset **/
$date = date("Y-m-d");
$time = date("H:i:s T");
$offset = date("P");
$utc = gmdate("H:i:s");
/***********************
* Start HTML output
***********************/
echo '<html><head><title>Magento Log File Contents on ' . $date . ' ' . $time . '</title>
<meta http-equiv="refresh" content="30">
<style type="text/css">html {width: 100%; font-family: Arial,Helvetica, sans-serif;}
body {line-height:1.0em; font-size: 100%;}
table {border-spacing: 1px;}
th.stattitle {text-align: left; font-size: 100%; font-weight: bold; color: white; background-color: #101010;}
th {text-align: center; font-size: 90%; font-weight: bold; padding: 5px; border-bottom: 1px solid black; border-left: 1px solid black; }
td {font-size: 90%; padding: 4px; border-bottom: 1px solid black; border-left: 1px solid black;}
</style>
</head><body>';
/** Output title, connection info and cron job monitor runtime **/
echo '<h2>Magento Log File Contents Report</h2><h3>Connection: '.$db['user'].'@'.$db['host'].' – Database: ' . $db['name'] . '</h3>';
echo '<h3>Runtime: ' . $date . ' ' .$time . ' ' . $utc . ' UTC</h3>';
echo '<h4>Note: Your timezone offset is ' . $offset . ' hours from UTC</h4>';
/** Connect to database **/
$conn = mysql_connect($db['host'],$db['user'],$db['pass']);
@mysql_select_db($db['name']) or die(mysql_error());
/***********************
* Get table record counts
***********************/
echo '<table><tbody><tr><th class="stattitle" colspan="2">Log Tables</th></tr>';
echo '<tr><th>Table</th><th>Row Count</th></tr>';
foreach($tables as $tblname) {
$result = mysql_query('SELECT COUNT(*) FROM ' . $db['pref'] . $tblname) or die(mysql_error());
$numrows = mysql_fetch_array($result);
$num = $numrows[0];
/* Table output */
echo '<tr>';
echo '<td>'.$db['pref'].$tblname.'</td>';
echo '<td align="right">'.$num.'</td>';
echo '</tr>';
}
echo '</tbody></table></body></html>';
/***********************
* End of report
***********************/
mysql_close($conn);
?>