Hi,
I have written a ConsoleCommand which runs awesome from Windows Command prompt and also linux terminal. My problem is that , when I add this command in the cron tab I get the following error when it is been executed.
This script must be run from the command line.
What could be the problem ?
PS: When I had register_argc_argv Off in my php.ini, I was not even able to run this command from terminal. When I turned it on, It started working from terminal but it is not at all working when I have it in crontab!
Please Help !
Page 1 of 1
Not Able To Run Consolecommand From Cron Tab
#2
Posted 18 March 2013 - 07:48 AM
You need to make sure your cron command runs in the same environment as your terminal.
The same user.
Uses the same php binary and config.
Maybe some ENV variables are not set.
The same user.
Uses the same php binary and config.
Maybe some ENV variables are not set.
#4
Posted 19 March 2013 - 03:06 AM
CeBe, on 18 March 2013 - 07:48 AM, said:
You need to make sure your cron command runs in the same environment as your terminal.
The same user.
Uses the same php binary and config.
Maybe some ENV variables are not set.
The same user.
Uses the same php binary and config.
Maybe some ENV variables are not set.
Thanks So much @CeBe !
I used to run the command from cron as
php /home/pathtomyapp/console.php myCommand
Now I modified it to
/usr/local/bin/php /home/pathtomyapp/console.php myCommand
and that did it !
#5
Posted 19 March 2013 - 09:29 AM
I always wonder, why so many people use custom console.php or similar things when this is absolutely not neccessary. I mean, the steps to create a custom console command are really simple and described well in the documentation:
1. Create a class that extends from CConsoleCommand and put it into your protected/commands folder
2. Call the command from yiic in your protected directory: /path/to/my/project/protected/yiic myCommand
Why all the fuss?
1. Create a class that extends from CConsoleCommand and put it into your protected/commands folder
2. Call the command from yiic in your protected directory: /path/to/my/project/protected/yiic myCommand
Why all the fuss?
Share this topic:
Page 1 of 1

Help












