Calling Craft Console Commands from Plugin?
Since Yii treats console commands like requests, you need to perform the following steps to execute a Craft console command from within a plugin:


Within your plugin, set the namespace to match the commands namespace
Call a run action from your plugin, and pass the route name/params


    MyPlugin::$plugin-&gt;getInstance()-&gt;controllerNamespace = 'craft\console\controllers';

    $command = MyPlugin::$plugin-&gt;getInstance()-&gt;runAction('gc/run');