2013-08-01 58 views
0

我現在有一個PHP ChronJob,使我的數據庫的日常備份,並且腳本如下:獲取mysqldump的調試信息

<?php 
set_time_limit(86000); 
include($_SERVER['DOCUMENT_ROOT']."/pagetop.php"); 
$db = new dbsettings; 
$filename = date("d-m-Y"); 
$output = array(); 
$output = shell_exec("C:\wamp\bin\mysql\mysql5.6.12\bin\mysqldump.exe --user=".$db->username." --password=".$db->password." --host=".$db->hostname." --add-drop-database --add-drop-table --skip-extended-insert --disable-keys --add-locks --force --debug-info ".$db->databaseName." > ".$_SERVER['DOCUMENT_ROOT']."backups/".$filename.".sql"); 
//Write backup log 
$file = fopen($_SERVER['DOCUMENT_ROOT']."backups/backup.log", "a"); 
fwrite($file, "\n\r".print_r($output, true)."\n\r"); 
fclose($file); 
?> 

這一切都完美的作品,以正確的格式創建一個SQL文件,但我不能爲我的生命寫入調試信息日誌,即使我有--debug-info參數,該參數:

Print debugging information and memory and CPU usage statistics when the program exits.

如何正確地將此信息寫入到一個文件?

+0

--debug [= debug_options], - #[debug_options] 編寫一個調試日誌。典型的debug_options字符串是'd:t:o,file_name'。默認值是'd:t:o,/ tmp/mysqldump.trace'。 – Hackerman

+0

@RobertRozas我剛剛嘗試過,並且我在Apache錯誤日誌中使用了'mysqldump:ERROR:Option'debug ='d:t:o,/ backups/mysqldump.trace'',但已禁用' –

+0

http:///www.mydigitallife.info/how-to-disable-and-turn-off-apache-httpd-access-and-error-log/ – Hackerman

回答

1

這個選項似乎並沒有在Windows上工作。我並不感到驚訝,因爲這些信息在Linux系統上比在Linux上要少得多,而且MySQL人員也許並沒有考慮移植這個小小的選項。

在Linux上,調試信息發送到stderr(您通常會以2>debug.log重定向捕獲此信息)。

+0

我會把這個打開一段時間,以防萬一有人有解決方案。但我認爲這絕對沒有什麼事情發生,沒有錯誤信息;就像它被忽略會導致我認爲你是正確的! –