Running cron in Yii2

I am using the yii2 template extended application and I want to create cron. I could find only a little information when searching on a topic and still found that cron jobs should be in the console folder.

my structure:

backend/
. 
.
.
console/
    models/
        Subscriptions.php   // my custom table model
    .
    .
    .       
    controllers/
        TimelineController.php
    .
    .
    .

I do not know where to start or how to continue? How to start cron?

LAMP.

+4
source share
2 answers

ok I had to go to the root of the project in the terminal, there is a script called yii, I used the following command to start cron:

php yii cronName.

for example, a cron controller named FirstController should start as follows:

rootFolderName / php yii first

+5
source

In your application \ console \ controllers \ SampleController   

class SampleController extends Controller {
        public function actionIndex() {
            echo "cron service runnning";
        }

.

   `php yii sample/index`

cron service runnning

+10

All Articles