问题描述
我创建了一个需要每月运行的Yii命令。如果我转到我的受保护的文件夹并手动运行该命令:
protected / yiic ganadores
它工作正常。我试图添加以下命令行到 etc / cron.hourly
和 etc / crontab
没有成功: / p>
/ usr / bin / php5 / var / www / path / to / project / protected / yiic ganadores
/cron.hourly/ganadores)
0 0 1 * * root / usr / bin / php5 / var / www / path / to / project / protected / yiic ganadores
(etc / crontab)
如果我运行文件
ganadores 里面 etc / cron.hourly
手动,它也工作。
?
编辑:最后得到解决。我在cron线有一些额外的空间。
解决方案这是我运行我的Yii cron作业(在根crontab文件):
45 23 * * * sudo -u www-data php / path / to / yii / app / protected / console .php mycommand
基本上只是普通的crontab语法,但我运行console.php而不是yiic,我设置用户到Apache(www-data),所以权限是正确的我的脚本。我不知道为什么你的工作,但希望看我的,将帮助你。 :)
I have created a Yii command that needs to be run every month. 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:
/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)
If I run the file ganadores
inside etc/cron.hourly
manually, it's working also.
What am I missing here?
Edit: Finally got it solved. I had some extra spaces in the cron line. Used tab instead spaces and it started working..
解决方案 This is how I run my Yii cron jobs (in the root crontab file):
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. I am not sure why yours isn't working, but hopefully looking at mine will help you out. :)
这篇关于Yii和cron工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!