【问题标题】:How to make a cronjob with modules in codeigniter?如何使用 codeigniter 中的模块制作 cronjob?
【发布时间】:2014-03-03 08:50:18
【问题描述】:

我想做一个 cronjob 来向用户发送有关某事的提醒??

我正在使用带有模块方法的 codeigniter 框架。

这是我最后一次尝试:

0 7 3 * * /usr/bin/php index.php cli/cart_reminder

虽然我使用模块,但我在 Controllers 文件夹中制作了一个单独的控制器

这是我的代码:

class Cart_Reminder extends CI_Controller {

    function __construct() 
    {
        parent::__construct();
        $this->load->library('input');
        $this->load->library('email');
        $this->load->model('cart_reminder_model','cart_reminder');
    }

    public function index()
    {
//         if(!$this->input->is_cli_request())
//      {
//          echo "greet my only be accessed from the command line";
//          return;
//      }

        $emails=$this->cart_reminder->get_emails();

        foreach($emails as $em):
          $msg=$em['bo_name'].'\r\n';
          $msg.="هذه الكتب قد فمت بإضافتهالسلة المشتريات من قبل ولم تقم بإكمال عملية الشراء لإكمال عملية الشراء اضغط هنا ";
          $msg.="<a href='".base_url()."paypal/cart'>اضغط هنا</a>";
          $this->email->to($em['user_email']);
          $this->email->from($this->option->get('site_email'));
          $this->email->subject("رسالة تذكير");
          $this->email->message($msg);
          $this->email->send();      

        endforeach;
    }


}

现在它不起作用并以管理员身份向我发送此邮件:

/usr/local/cpanel/bin/jailshell: 0: 找不到命令

【问题讨论】:

    标签: php codeigniter cron


    【解决方案1】:

    您需要做两件事(在命令提示符下):

    1) 确保 PHP 确实位于 @ /usr/bin/php

    /usr/bin/php --version
    

    2) 将完整路径添加到 crontab 条目:

    0 7 3 * * /usr/bin/php /home/users/test.com/index.php cli/cart_reminder
    

    最后,一旦你有了该命令集,请执行以下操作以确保它确实有效:

    >cd $HOME
    >/usr/bin/php /home/users/name/sites/test.com/index.php cli/cart_reminder
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-12
      • 2016-11-14
      • 1970-01-01
      • 2012-11-16
      • 1970-01-01
      • 2015-02-25
      • 1970-01-01
      相关资源
      最近更新 更多