Automatic cron jobs in yii2

I was reading this wiki article about implementing cron in yii2.

I have 2 questions:

  1. How can I make cron task that will execute automatically at certain period every day. For example I want to send emails to site clients at 6AM every day.

  2. What if I want to create cron job that will do some database operations at certain time every day. For example I want to run few SQL queries to pick up some information from some tables and then based on those infos update some other table. Is this possible ?

Thanks

1 Like
  1. You make cron jobs on your server operating system. The cron jobs should be set to run your PHP script at some appointed time(s).

  2. Yes, it is possible. I think the easiest way is to create a console command. http://www.yiiframework.com/doc-2.0/guide-tutorial-console.html

Once completed set your cron job to run your console command at the time you specify

1 Like

Thank you!