[英]Yii and cron jobs
I have created a Yii command that needs to be run every month. 我创建了一个需要每月运行的Yii命令。 If I go to my protected folder and run the command manually:
如果我转到受保护的文件夹并手动运行该命令:
protected/yiic ganadores
It works fine. 它工作正常。 I have tried to add the following command line to
etc/cron.hourly
and etc/crontab
with no success: 我试图将以下命令行添加到
etc/cron.hourly
和etc/crontab
没有成功:
/usr/bin/php5 /var/www/path/to/project/protected/yiic ganadores
(etc/cron.hourly/ganadores) /usr/bin/php5 /var/www/path/to/project/protected/yiic ganadores
(etc / cron.hourly / ganadores)
0 0 1 * * root /usr/bin/php5 /var/www/path/to/project/protected/yiic ganadores
(etc/crontab) 0 0 1 * * root /usr/bin/php5 /var/www/path/to/project/protected/yiic ganadores
(etc / crontab)
If I run the file ganadores
inside etc/cron.hourly
manually, it's working also. 如果我手动在
etc/cron.hourly
运行文件ganadores
,它也可以正常工作。
What am I missing here? 我在这里错过了什么?
Edit: Finally got it solved. 编辑:终于解决了。 I had some extra spaces in the cron line.
我在cron线上有一些额外的空格。 Used tab instead spaces and it started working..
使用选项卡代替空格,它开始工作..
This is how I run my Yii cron jobs (in the root crontab file): 这就是我运行Yii cron作业的方法(在根crontab文件中):
45 23 * * * sudo -u www-data php /path/to/yii/app/protected/console.php mycommand
Basically just regular crontab syntax, but I am running console.php instead of yiic, and I am setting the user to Apache (www-data) so the permissions are correct for my script. 基本上只是常规的crontab语法,但我运行的是console.php而不是yiic,我将用户设置为Apache(www-data),因此权限对我的脚本是正确的。 I am not sure why yours isn't working, but hopefully looking at mine will help you out.
我不确定你为什么不工作,但希望看着我的工作会帮助你。 :)
:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.