PHP로 Excel 파일의 내용을 기반으로 동적 cron 작업을 예약하고이 값을 스크립트에 argv
으로 전달합니다.Cron Job이 PHP 스크립트에 대한 인수를 등록하지 않은 것으로 보입니다. 그러나 해당 스크립트는 예외로 구성됩니다.
$data = new SpreadSheet_Excel_Reader("sample-data.xls", false);
$surveyToken = "Token";
$email = rawurlencode($data->val(2, "B"));
$dateCompleted = rawurlencode($data->val(2, "C"));
$followUpOne = rawurlencode($data->val(2, "E"));
$followUpTwo = rawurlencode($data->val(2, "F"));
$programName = rawurlencode($data->val(2, "G"));
$subject = rawurlencode($data->val(2, "H"));
$firstName = rawurlencode($data->val(2, "I"));
$lastName = rawurlencode($data->val(2, "J"));
$learningGoal = rawurlencode($data->val(2, "K"));
$importanceScore = rawurlencode($data->val(2, "L"));
$confidenceScore = rawurlencode($data->val(2, "M"));
$strategies = rawurlencode($data->val(2, "N"));
$timeLine = rawurlencode($data->val(2, "O"));
$measures = rawurlencode($data->val(2, "P"));
$resources = rawurlencode($data->val(2, "Q"));
$output = shell_exec("crontab -l");
file_put_contents("crontab.txt", $output . "39 * * * * /usr/local/php53/bin/php mail.php $surveyToken $email $dateCompleted $followUpOne $followUpTwo $programName $subject $firstName $lastName $learningGoal $importanceScore $confidenceScore $strategies $timeLine $measures $resources" . PHP_EOL);
exec("crontab crontab.txt");
나는 mail.php 스크립트에서 원시 URL 디코딩을 사용하고 argv
에서 변수를 얻어서 이메일을 보내고있다 : 다음과 같이 내 코드입니다.
나는이 스크립트를 출력 된 "url"및 인수와 함께 명령 줄에서 실행하고 cron 작업을 예약하지 않음으로써이 스크립트를 테스트했습니다.
이렇게 실행하면 정상적으로 작동합니다. 위의 코드를 실행하면 cron 작업이 제대로 작동하고 php 파일이 나에게 이메일을 보내지만 모든 변수는 argv
에서 비어 있습니다.
실행했을 때 crontab -l 또는 -e (또는 crontab.txt보기/편집) 할 수 있으며 매개 변수에 특수 문자가 없는지 mail.php 스크립트를 깨뜨릴 수 있습니까? –
$ email 매개 변수에서 얻은 이메일 주소 또는 mail.php 스크립트에 내장 된 이메일 주소는 무엇입니까? –