我想做一个cronjob来向用户发送有关某事的提醒??
我正在使用带有模块方法的代码点火器框架。
这是我的最后一次尝试:
0 7 3 * * /usr/bin/php index.php cli/cart_reminder
虽然我使用模块,但我在控制器文件夹中制作了一个单独的控制器
这是我的代码:
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'].'rn';
$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:找不到命令
您需要
做两件事(从命令提示符):
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