发出执行CRON Job的问题

时间:2016-11-27 18:41:59

标签: php cron

我已经设置了一个cron作业来为我的客户发送电子邮件会议提醒,但它似乎没有起作用。然而,当我手动加载页面时,它的工作原理和回声都很好。有人可以帮忙吗?

我正在尝试运行的脚本如下所示。

require('../../dbconfig.php');
$sql    = " SELECT email, name, webinar_date FROM webinar_list";
$query  = mysqli_query($conn, $sql);
while ($row=mysqli_fetch_assoc($query))
{

    $email = $row['email'];
    $name = $row['name'];
    $webinarTime=$row['webinar_date'];
    echo "current time = ".$currentTime=time(); echo "<br>";
    echo "registered time = ".$registeredTime=strtotime($row['webinar_date']); echo "<br>";
    echo "Difference = ".$timeDiff=$currentTime - $registeredTime;

    //IF TIME DIFFERENCE IS <60 MIN BUT LESS THAN 55MIN
    if(($timeDiff<=3600)&&($timeDiff>=3300))
    {
         $message = oneHour($name); 
         echo $message;
         $from    = "reminder@theleagueoffreedom.com";
         $to      = $email;
         $subject = 'Just A Friendly Reminder...';
         $headers = "From:  Anthony Moto \r\n";
         $headers .= "MIME-Version: 1.0\r\n";
         $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
         mail($to,$subject,$message, $headers);
    }
    //IF TIME DIFFERENCE IS <10 MIN BUT GREATER THAN 5MIN
    elseif(($timeDiff<=600)&&($timeDiff>=300))
    {   
         $message = tenMinutes($name); 
         echo $message;
         $from    = "reminder@EXAMPLE.com";
         $to      = $email;
         $subject = 'RE:10 Minutes...';
         $headers = "From:  Anthony Moto \r\n";
         $headers .= "MIME-Version: 1.0\r\n";
         $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
         mail($to,$subject,$message, $headers);
    }
    //IF TIME DIFFERENCE IS <5 MIN BUT LESS THAN -5MIN
    elseif(($timeDiff<=300)&&($timeDiff>=-300))
    {
         $message = liveTraining($name);
         echo $message;
         $from    = "reminder@EXAMPLE.com";
         $to      = $email;
         $subject = 'We Are Starting NOW!';
         $headers = "From:  Anthony Moto \r\n";
         $headers .= "MIME-Version: 1.0\r\n";
         $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
         mail($to,$subject,$message, $headers);
    }
}

我在我调用的函数中返回$ message变量,这是一串字母。 我的cron工作看起来像这样。

*/10    *   *   *   *   /usr/local/bin/php -q /home/username/public_html/example.com/webinar_emails/p0/webinar_reminder.php

如果有帮助,则currentTime取自SQL,它采用以下格式:

2016-11-27 11:00:00

我遇到的问题是我根本没有收到任何电子邮件。我也检查了我的垃圾邮件文件夹。我甚至没有收到“空白”电子邮件。就像我说的那样,代码回显出当前的时间和时差就好了。但是Cron似乎没有运行脚本。

任何帮助都将不胜感激,我将永远感激不尽!

由于

0 个答案:

没有答案