我有下面的代碼,我在cron運行,cron作業不執行和返回錯誤
<?php
$_SERVER['DOCUMENT_ROOT'] = dirname(__FILE__);
$directory = $_SERVER["DOCUMENT_ROOT"]."/cron/";
$file = "register_warranty_". date("dMY") .".csv";
$filepath = $directory.$file;
if(!file_exists($filepath))
{
$fp = fopen($filepath, "w+");
fwrite($fp, "Title, Initials, Surname, HomeTel, Mobile, HouseNumber, Address, Address2, Town, Postcode, NewlyBuiltHome, InstallationDate, Houseowner, InstallersName, InstallersEmail, InstallersMobile, InstallersGasSafeNumber, BusinessName, BusinessAddress, BusinessAddress2, BusinessTown, BusinessRegion, BusinessPostcode, BusinessGasSafeNumber, BusinessEmail, SuppliersName, Model, serial, MaintenanceContract, ExpiryDate, Donotwishtobecontactedviapost, Donotwishtobecontactedviatelephone, Donotwishtobecontactedviaemail, Donotwishtobecontactedviasms\n");
fclose($fp);
}
>
在克龍的電子郵件運行的cron當我 - 我得到以下錯誤,
線1:PHP:沒有這樣的文件或目錄
線3:鄰近語法錯誤意外的標記('
$ _SERVER [ 'DOCUMENT_ROOT'] =目錄名(FILE);'
line 3:
我在做什麼明顯錯誤,我不是最有經驗的克倫工作。
在/ usr/bin中/ PHP -f myscript.php應該用來代替PHP myscript.php [/ usr/bin /是執行php的示例路徑,找到你的..在shell中輸入哪個php] – donald123