douhe6181 2015-06-30 07:57
浏览 50

虽然在PHP脚本中无法运行的循环在Crontab中运行

I have a php script running as a crontab job.

When I run the file in a browser, the loops executes perfectly but when running in crontab is only executes the first iteration with no output errors.

Any ideas why? I utterly stumped!!!.

the crontab entry: /usr/bin/php /home/XXX/public_html/directory/cron/cron.php 2>&1 >> /home/XXX/public_html/directory/cron/script_output.log | mail -s "Cronjob PSTART Daily" me@XXX.com

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();
?>
  • 写回答

1条回答 默认 最新

  • dpbfb7119 2015-07-01 19:57
    关注

    never got to the bottom of this issue but fixed it by running the url via curl rather than running the php script directly from the php:

    /usr/bin/curl -u uname:password --silent --compressed http://www.domain.net/dir/cron/cron.php

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。