我有一个php脚本作为crontab作业运行。
当我在浏览器中运行该文件时,循环完美地执行,但当在crontab中运行时,只执行第一次迭代,没有输出错误。
有什么原因吗?我彻底傻眼了!!!。
crontab条目:usrbinphp homeXXXpublic_htmldirectorycroncron.php 2>&1>> homeXXXpublic_htmldirectorycronscript_output.log usrbincurl -u uname:password --silent --compressed
http:/www.domain.netdircroncron.php
<?php
$members = new WA_MySQLi_RS("members", $alpha, 0);
$members->setQuery("SELECT
registration.*,
child_base_smqf.child_base_smqf_id,
child_base_smqf.child_base_smqf_uid,
child_base_smqf.child_base_smqf_open_timestamp,
child_base_smqf.child_base_smqf_close_timestamp,
parent_base_smqf.parent_base_smqf_id,
parent_base_smqf.parent_base_smqf_uid,
parent_base_smqf.parent_base_smqf_open_timestamp,
parent_base_smqf.parent_base_smqf_close_timestamp
FROM registration
LEFT JOIN child_base_smqf ON registration.rego_parent_uid = child_base_smqf.child_base_smqf_uid
LEFT JOIN parent_base_smqf ON registration.rego_parent_uid = parent_base_smqf.parent_base_smqf_uid
WHERE
registration.rego_parent_acc_status != 0 AND # NOT OPTED OUT
child_base_smqf.child_base_smqf_close_timestamp IS NOT NULL AND # CHILD BASELINE SURVEY HAS BEEN COMPLETED
parent_base_smqf.parent_base_smqf_close_timestamp IS NULL # PARENT BASELINE SURVEY HAS NOT BEEN COMPLETED
GROUP BY `rego_parent_uid`
ORDER BY `rego_id` ASC");
$members->execute();
while (!$members->atEnd()) {
// !DEFINE VARIABLES
require('cronVariables.php');
echo $members->getColumnVal("rego_parent_uid") . ' - ' .$members->getColumnVal("rego_parent_fname") . " STAMP - " . $members->getColumnVal("child_base_smqf_close_timestamp") . " baseline email reminders - " . $parent_base_surveyReminderTrigger . "<br>";
require('parentBaseReminderEmails.php');
$members->moveNext();
?>
在循环中使用 "require "而不是 "require_once "会导致一个致命的错误,当再次打到require时,会在下一次迭代中终止。
"Fatal error: 无法重新声明xyz"。但这是在不知道那些 "require "位包含的情况下的猜测。为了避免你因挫折而发疯,第1步是确保你得到所有的日志输出。
在第1行插上一个快速的,当完成调试后删除,或者说,当完成后将display_errors设置为0。