首页 文章

如何使用codeigniter在cpanel中运行cron

提问于
浏览
0

如何使用codeigniter在cpanel中运行cron

<?php

class Cron extends CI_Controller {

    public function __construct()
    {
        parent::__construct();

    $this->load->model('customerdata_model');

    }

    public function index()
    {

        $c_date = date('Y-m-d');
        $remider_data   = $this->customerdata_model->get_customer_remider_data(array('status'=>'1', 'reminder_date_before' => $c_date));
        foreach($remider_data as $remider_data_mail)
        {
                    $mailTo  = $remider_data_mail->reminder_email;
                    $nameTo = $remider_data_mail->reminder_email;

                    $mailFrom  ="karthigesh@stallioni.com";
                    $nameFrom  = "Arya project Board";

                    $subject  ="reminder_date_before";
                    $body     =  $remider_data_mail->reminder_description;          

                $headers = "Content-type: text/html;\n";
                $headers .= "From: ". $nameFrom . " <" . $mailFrom . ">\n";                
                $headers .= "Reply-To: ". 'no-reply@stallioni.com' . " <" . 'Arya Project Board' . ">\n";
                $headers .= "Return-Path: " . $mailFrom ."\n";

                    if(mail($mailTo, $subject, $body, $headers))
                    {
                        echo 'email sent';
                    }
        }


    }

}

这是我的controller-> Cron文件 .

我正在使用索引功能来使用Cron作业 .

我在cpanel / usr / bin / php /home/***/public_html/***/index.php cron index中设置

我还使用php /full-path-to-cron-file/cron.php / test / index

2 回答

  • 0

    您可以从命令行调用codeigniter:

    php /var/www/ci_folder/index.php controller_name function_name
    

    参考这里:https://www.codeigniter.com/userguide3/general/cli.html

  • 0

    我不知道为什么,

    php /path/to/the/project/index.php控制器功能

    不适合我,但这对我有用

    php /path/to/the/project/index.php控制器/功能

    注意控制器和功能之间的“/” .

相关问题