Yii2 cronjob using

Hi ,
I use basic template and I want to run anyone action with crontab. I installed yii2-scheduling extension.
i created schedule.php file to /var/www/html/basic/config/ as like this.

<?php

$schedule->exec('touch /var/www/html/a.txt')->everyMinute();
 
?>

I try to create a.txt file every minutes at this command.
After this , I added this line int /etc/crontab

* * * * * php /var/www/html/basic/yii schedule/run --scheduleFile=/var/www/html/basic/config/schedule.php
and I wait it’s work. But not work.

If I run this command on command line “php /var/www/html/basic/yii schedule/run” it is works and a.txt file created. But crontab not work.

When adding cronjobs to /etc/crontab, you must specify the user field.

It should read:

* * * * *  USER php /var/www/html/basic/yii schedule/run --scheduleFile=/var/www/html/basic/config/schedule.php
1 Like

Thank you very much.

1 Like