I'm using the advanced template application of yii2 and i want to create a cron. I could find only little information while googling the subject and so far found that cron jobs should go in the console folder.
my structure:
backend/
.
.
.
console/
models/
Subscriptions.php // my custom table model
.
.
.
controllers/
TimelineController.php
.
.
.
I don't know where to go from now or how to proceed? How can I run the cron?
LAMP environment.
In your app\console\controllers\SampleController
class SampleController extends Controller {
public function actionIndex() {
echo "cron service runnning";
}
In your terminal,from your application root folder,run..
`php yii sample/index`
You should get like cron service runnning
ok i had to navigate to the root of the project in the terminal, there exists a script named yii, i used the following command to run the cron:
php yii cronName.
for example a cron controller named FirstController should be run like this:
rootFolderName/ php yii first
In yii2, command which worked for me is:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With