Install in \ console \ config \ main.php
return [ 'id' => 'app-console', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'], 'controllerNamespace' => 'console\controllers', 'components' => [ 'log' => [ 'targets' => [ [ 'class' => 'yii\log\FileTarget', 'levels' => ['error', 'warning'], ], ], ], 'user' => [ 'class' => 'yii\web\User', 'identityClass' => 'app\models\Credential',
now in your \ console \ controller \ AbcController.php add the init method
public function init() { parent::init(); Yii::$app->user->setIdentity(Credential::findOne(['id'=><cronloginid>])); }
create a cron account and pass this login id to a variable with this configuration, your Blamingable of yii2 behavior will work
source share