Yii and cron jobs

倾然丶 夕夏残阳落幕 提交于 2019-12-06 08:44:37

问题


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..


回答1:


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. :)



来源:https://stackoverflow.com/questions/5235888/yii-and-cron-jobs

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!