M
M
madphoenix2016-02-02 13:51:33
Yii
madphoenix, 2016-02-02 13:51:33

How to use Yii2 console controller and cron on shared hosting?

Hello! Can you please tell me how to use Yii2 console controller and cron on shared hosting?
There is hosting from aghost and DirectAdmin. In the cron settings, I'm trying to run an action from a console controller.
I tried commands like this:
10 * * * * cd /home/user/domains/test.com/public_html/planner && /usr/local/bin/php yii currency/download
10 * * * * /usr/local/bin/ php /home/user/domains/test.com/public_html/planner yii currency/download
10 * * * * /usr/local/bin/php /home/user/domains/test.com/public_html/planner/yii currency/ download
Nothing happens in the first two cases, nothing is written to the logs.
In the latter case, an error message goes into the log:

2016-02-02 10:20:02 [-][-][-][error][yii\console\Exception] exception 'yii\base\InvalidRouteException' with message 'Unable to resolve the request "currency/download".' in /home//domains//public_html/planner/vendor/yiisoft/yii2/base/Module.php:460
Stack trace:
#0 /home//domains//public_html/planner/vendor/yiisoft/yii2/console/Application.php(167): yii\base\Module->runAction('currency/downlo...', Array)
#1 /home//domains//public_html/planner/vendor/yiisoft/yii2/console/Application.php(143): yii\console\Application->runAction('currency/downlo...', Array)
#2 /home//domains//public_html/planner/vendor/yiisoft/yii2/base/Application.php(375): yii\console\Application->handleRequest(Object(yii\console\Request))
#3 /home//domains//public_html/planner/yii(19): yii\base\Application->run()
#4 {main}

Next exception 'yii\console\Exception' with message 'Unknown command "currency/download".' in /home//domains//public_html/planner/vendor/yiisoft/yii2/console/Application.php:169
Stack trace:
#0 /home//domains//public_html/planner/vendor/yiisoft/yii2/console/Application.php(143): yii\console\Application->runAction('currency/downlo...', Array)
#1 /home//domains//public_html/planner/vendor/yiisoft/yii2/base/Application.php(375): yii\console\Application->handleRequest(Object(yii\console\Request))
#2 /home//domains//public_html/planner/yii(19): yii\base\Application->run()
#3 {main}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dima Barsukov, 2016-02-02
@madphoenix

If you have ssh before hosting, log in to the console (for example, through Putty, or with another client). Run the command php -f /path/to/yii/console controller/action. See errors.
When everything works, write everything after -f to cron.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question