Running a cronjob in shared hosting

HI

I can’t find a way to run a cronjob for a yii command in a shared hosting linux.

Can somebody guide me, please?

More details, please :)

But, to run a cron job, you need to provide the full path for everything:

Like:


/user/bin/php /home/yourname/yourapp/yii controller/command

Sure. I forgot the details.

here is the error I receive:


/bin/sh: /home/[myusername]/public_html/yii: /usr/bin/php: bad interpreter: No such file or directory

here is the yii code


#!/usr/bin/php -q

<?php

/**

 * Yii console bootstrap file.

 *

 * @link http://www.yiiframework.com/

 * @copyright Copyright (c) 2008 Yii Software LLC

 * @license http://www.yiiframework.com/license/

 */


defined('YII_DEBUG') or define('YII_DEBUG', true);


// fcgi doesn't have STDIN and STDOUT defined by default

defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));

defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w'));


require(__DIR__ . '/vendor/autoload.php');

require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php');


$config = require(__DIR__ . '/app/config/console.php');


$application = new yii\console\Application($config);

$exitCode = $application->run();

exit($exitCode);

And my Cron:


/home/[myusername]/public_html/yii status

Also I tried these without positive result:

#!/usr/bin/php

#!/usr/bin/env php

I guess you need to contact support to know which binary to use…

I told you that your cron command should include the PHP binary:


/usr/bin/php /home/yourusername/public_html/yii status

What the actual full name of the php cli executable is, varies enormously.

On my server, PHP is /package/host/localhost/php-7.0/bin/php

Solved.

I requested the correct php path from support. The path in their articles was old.

Thank you everyone for your helps.