public function actionStart($taskCommand = null )
    {
        /**
         * @var $cron Crontab
         */
        $cron = $this->module->get($this->module->nameComponent);
        $cron->eraseJobs();
        $common_params = $this->module->params;
        if(!empty($this->module->tasks)) {
            if($taskCommand && isset($this->module->tasks[$taskCommand])){

                    $task = $this->module->tasks[$taskCommand];
                    $params = ArrayHelper::merge( ArrayHelper::getValue($task, 'params',[]), $common_params );

                    $cron->addApplicationJob($this->module->phpPath.' '.$this->getYiiPath(), $task['command'],
                        $params,
                        ArrayHelper::getValue($task, 'min'),
                        ArrayHelper::getValue($task, 'hour'),
                        ArrayHelper::getValue($task, 'day'),
                        ArrayHelper::getValue($task, 'month'),
                        ArrayHelper::getValue($task, 'dayofweek'),
                        $this->module->cronGroup //mast be unique for any app on server
                    );

            } else {
                    foreach ($this->module->tasks as $commandName => $task) {

                        $params = ArrayHelper::merge( ArrayHelper::getValue($task, 'params',[]), $common_params );

                        $cron->addApplicationJob($this->module->phpPath.' '.$this->getYiiPath(), $task['command'],
                            $params,
                            ArrayHelper::getValue($task, 'min'),
                            ArrayHelper::getValue($task, 'hour'),
                            ArrayHelper::getValue($task, 'day'),
                            ArrayHelper::getValue($task, 'month'),
                            ArrayHelper::getValue($task, 'dayofweek'),
                            $this->module->cronGroup //mast be unique for any app on server
                        );
                    }
            }

            $cron->saveCronFile(); // save to my_crontab cronfile
            $cron->saveToCrontab(); // adds all my_crontab jobs to system (replacing previous my_crontab jobs)

            echo $this->ansiFormat('Cron Tasks started.' . PHP_EOL, Console::FG_GREEN);
        } else {
            echo $this->ansiFormat('Cron do not have Tasks.' . PHP_EOL, Console::FG_GREEN);
        }
    }
public function actionStart($taskCommand = null )
    {
        /**
         * @var $cron Crontab
         */
        $cron = $this->module->get($this->module->nameComponent);
        $cron->eraseJobs();
        $common_params = $this->module->params;
        if(!empty($this->module->tasks)) {
            if($taskCommand && isset($this->module->tasks[$taskCommand])){

                    $task = $this->module->tasks[$taskCommand];
                    $params = ArrayHelper::merge( ArrayHelper::getValue($task, 'params',[]), $common_params );

                    $cron->addApplicationJob($this->module->phpPath.' '.$this->getYiiPath(), $task['command'],
                        $params,
                        ArrayHelper::getValue($task, 'min'),
                        ArrayHelper::getValue($task, 'hour'),
                        ArrayHelper::getValue($task, 'day'),
                        ArrayHelper::getValue($task, 'month'),
                        ArrayHelper::getValue($task, 'dayofweek'),
                        $this->module->cronGroup //mast be unique for any app on server
                    );

            } else {
                    foreach ($this->module->tasks as $commandName => $task) {

                        $params = ArrayHelper::merge( ArrayHelper::getValue($task, 'params',[]), $common_params );

                        $cron->addApplicationJob($this->module->phpPath.' '.$this->getYiiPath(), $task['command'],
                            $params,
                            ArrayHelper::getValue($task, 'min'),
                            ArrayHelper::getValue($task, 'hour'),
                            ArrayHelper::getValue($task, 'day'),
                            ArrayHelper::getValue($task, 'month'),
                            ArrayHelper::getValue($task, 'dayofweek'),
                            $this->module->cronGroup //mast be unique for any app on server
                        );
                    }
            }

            $cron->saveCronFile(); // save to my_crontab cronfile
            $cron->saveToCrontab(); // adds all my_crontab jobs to system (replacing previous my_crontab jobs)

            echo $this->ansiFormat('Cron Tasks started.' . PHP_EOL, Console::FG_GREEN);
        } else {
            echo $this->ansiFormat('Cron do not have Tasks.' . PHP_EOL, Console::FG_GREEN);
        }
    }
public function actionStart ( $ taskCommand = null ) { /**
         * @var $cron Crontab
         */ $ cron = $ this -> module -> get ( $ this -> module -> nameComponent ) ; $ cron -> eraseJobs ( ) ; $ common_params = $ this -> module -> params ; if ( ! empty ( $ this -> module -> tasks ) ) { if ( $ taskCommand && isset ( $ this -> module -> tasks [ $ taskCommand ] ) ) { $ task = $ this -> module -> tasks [ $ taskCommand ] ; $ params = ArrayHelper :: merge ( ArrayHelper :: getValue ( $ task , 'params' , [ ] ) , $ common_params ) ; $ cron -> addApplicationJob ( $ this -> module -> phpPath . ' ' . $ this -> getYiiPath ( ) , $ task [ 'command' ] , $ params , ArrayHelper :: getValue ( $ task , 'min' ) , ArrayHelper :: getValue ( $ task , 'hour' ) , ArrayHelper :: getValue ( $ task , 'day' ) , ArrayHelper :: getValue ( $ task , 'month' ) , ArrayHelper :: getValue ( $ task , 'dayofweek' ) , $ this -> module -> cronGroup //mast be unique for any app on server ) ; } else { foreach ( $ this -> module -> tasks as $ commandName => $ task ) { $ params = ArrayHelper :: merge ( ArrayHelper :: getValue ( $ task , 'params' , [ ] ) , $ common_params ) ; $ cron -> addApplicationJob ( $ this -> module -> phpPath . ' ' . $ this -> getYiiPath ( ) , $ task [ 'command' ] , $ params , ArrayHelper :: getValue ( $ task , 'min' ) , ArrayHelper :: getValue ( $ task , 'hour' ) , ArrayHelper :: getValue ( $ task , 'day' ) , ArrayHelper :: getValue ( $ task , 'month' ) , ArrayHelper :: getValue ( $ task , 'dayofweek' ) , $ this -> module -> cronGroup //mast be unique for any app on server ) ; } } $ cron -> saveCronFile ( ) ; // save to my_crontab cronfile $ cron -> saveToCrontab ( ) ; // adds all my_crontab jobs to system (replacing previous my_crontab jobs) echo $ this -> ansiFormat ( 'Cron Tasks started.' . PHP_EOL , Console :: FG_GREEN ) ; } else { echo $ this -> ansiFormat ( 'Cron do not have Tasks.' . PHP_EOL , Console :: FG_GREEN ) ; } }
Start cron tasks
@param string $taskCommand
@throws \yii\base\InvalidConfigException
Start cron tasks