
如何記錄執行命令的輸出在?
該命令實際上是exec()
由 PHP 執行的,如下所示:
<?php
exec('echo "curl -k https://localhost/projekt/crons/purge/5" | at now + 5 minutes');
我需要捕獲來自curl 請求的回應並將其記錄到文件中。手冊頁指出:
使用者將收到其命令的標準錯誤和標準輸出(如果有)。將使用命令發送郵件
/usr/lib/sendmail
。如果在是從一個執行的 蘇(1)shell,登入 shell 的擁有者將收到郵件。
誰擁有該郵件(www-data?),我該如何存取它?這些文件是指屬於使用者的作業系統郵件,還是實際的電子郵件?謝謝!
答案1
嘗試這個:
$ echo "curl -k https://localhost/projekt/crons/purge/5 > projekt.log 2>&1" | at now + 5 minutes