使用cpanel在codeigniter中的cronjob [英] cronjob in codeigniter using cpanel
问题描述
我的网站托管服务器是hostmonster.com。
My website hosting server is hostmonster.com.
我的应用程序使用codeigniter框架。
My application uses codeigniter framework.
我有
我使用了托管服务的面板,并尝试将命令设置为
I have used the cpanel of the hosting service and I tried to give the command as
php -q www.mysite.com/admin admin sendDailyEmail
我的控制器是admin,方法是sendDailyEmail,并且该控制器位于application / controllers / admin文件夹中。
my controller is admin and the method is sendDailyEmail and the controller is present inside the application/controllers/admin folder.
每当cronjob运行时,我也会给我设置提醒电子邮件。
I have also set a reminder email to me whenever the cronjob is run.
电子邮件主题为
Cron php -q / home1 / username / public_html / admin admin sendDailyEmail
Cron php -q /home1/username/public_html/admin admin sendDailyEmail
然后正文说
未指定输入文件
No input file specified
我在哪里会出错。
我从未运行过cronj obs,这是我第一次。
我也不擅长提供命令行指令。
I have never run cronjobs and this is my first time. I am no good in giving command line instuctions too.
我的管理员sendDailyEmail代码如下
My admin sendDailyEmail code is as follows
function sendDailyEmail() {
$data = $this->admin_model->getDailyData();
foreach ($data as $u) {
if($u->Daily){
//if(!$u->Amount){
if ($u->Email=='myemail@gmail.com') {
$user['user_data']['FirstName'] = $u->FirstName;
$user['user_data']['LastName'] = $u->LastName;
$user['user_data']['Id']=$u->Id;
$this->email->clear();
$this->email->to($u->Email);
$this->email->from('alerts@mysite.com', 'MySite');
$this->email->subject("My Subject");
$msg = $this->load->view('emails/daily_view', $user, true);
$this->email->message($msg);
if ($this->email->send())
$data['message'] = "Daily Emails has been sent successfully";
else
$data['message'] = "Daily Emails Sending Failed";
}
}
}
$data['main_content']['next_view'] = 'admin_home_view';
$this->load->view('includes/admin_template', $data);
}
推荐答案
您可以使用 wget
并设置您喜欢的时间:
You can use wget
and set the time for whatever you like:
wget http://www.mysite.com/admin/sendDailyEmail
您也可以使用 curl
:
curl --silent http://www.mysite.com/admin/sendDailyEmail
这篇关于使用cpanel在codeigniter中的cronjob的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!