我正在尝试为我的模块中的特定路由定义发送电子邮件的路径设置cron:
路线如下:
'company-testing' => array( //Company Invoice Page
'type' => 'Segment',
'options' => array(
'route' => '/account/company-testing[/:action]',
'defaults' => array(
'controller' => 'Company\Controller\CouponOrder',
'action' => 'tempTesty',
),
),
'may_terminate' => true,
),
根据上述配置,此路线的页面网址如下:
http://shop.projekte-web.com/reisesparer/public/account/company-testing
所以我尝试通过以下方式通过CLI设置cron,但它无法正常工作,也没有发送具有指定cron时间的电子邮件。
但如果我直接点击该路线,它会生成电子邮件并成功发送。
CRON SETUP:
* * * * * /usr/bin/php /absolute_path_to_my_project/public /account/company-testing > / dev / null 2> & 1
有关此问题的任何帮助吗?
答案 0 :(得分:0)
我建议您创建一个控制台路由以使用Zend Framework完成cron作业。因此,如果您创建了类似于以下
的控制台路由'console' => array(
'router' => array(
'routes' => array(
'cron-company-testing' => array(
'options' => array(
'route' => 'cronmail', // route to be used in cli
'defaults' => array(
'controller' => 'Company\Controller\CouponOrder',
'action' => 'tempTesty',
),
),
),
),
),
),
将以上配置添加到module.config.php
。
首先让我们在本地通过终端进行检查。在终端中执行以下操作
cd /path/to/your/project
php public/index.php cronmail
接下来,您可以向crontab
添加作业。请查看路线名称,在本例中为cronmail
。
* * * * * /usr/bin/php /path/to/project/public/index.php cronmail &> /dev/null
现在您应该检查该作业是否已添加到crontab
。在终端中使用以下命令
crontab -l