在Yii 1.1中执行的子文件夹应用程序中执行cron作业时出错

时间:2018-02-11 06:38:41

标签: yii cron

我有以下为webApi编写的代码,它在手动运行时有效。

    public function actionProcesspush()
{
    $date = 'Today is '.date("D M d, Y G:i", time());
    echo $date;
    // the message
    $msg = $date."First okok line of text\nSecond line of text";

    // use wordwrap() if lines are longer than 70 characters
    $msg = wordwrap($msg,70);

   // send email
  if(@mail("me@swapnil.tech", "My Test New Cron ok ok", $msg))
  {
     echo "Mail Sent Successfully okokok";
  }else{
  echo "Mail Not Sent";
  }
}

如果我把它放在主站点的Cron Job中,这段代码就可以了。但是当我在public_html中的子文件夹中复制我的系统时,代码正在手动运行。但Cron执行没有完成。我将应用程序复制到了public_html中的“testingnoundersore”文件夹中。 错误日志会出现以下错误。

thrown in /home/takeawayjunkies/public_html/yiiframework/web/CWebApplication.php on line 286
[11-Feb-2018 06:11:03 UTC] PHP Fatal error:  Uncaught exception 'CHttpException' with message 'Unable to resolve the request "testingnoundersore/mobileapp/cron/processpush".' in /home/takeawayswapnil/public_html/yiiframework/web/CWebApplication.php:286
Stack trace:
#0 /home/takeawayswapnil/public_html/yiiframework/web/CWebApplication.php(141): CWebApplication->runController('testingnounders...')
#1 /home/takeawayswapnil/public_html/yiiframework/base/CApplication.php(185): CWebApplication->processRequest()
#2 /home/takeawayswapnil/public_html/index.php(50): CApplication->run()

1 个答案:

答案 0 :(得分:0)

我在这里找到了答案。 https://www.inmotionhosting.com/support/edu/cpanel/how-to-run-a-cron-job 正如在VPS上设置的Cron Jobs与共享托管不同。

普通卷曲命令

curl "https://www.takeawayswapnil.com/test_environment/merchantapp/cron/processpush"

for VPS

curl --user-agent cPanel-Cron "https://www.takeawayswapnil.com/test_environment/merchantapp/cron/processpush"