VestaCP Yii2 cron job

Ubuntu 14.04 trusty

VestaCP v0.9.8

yii2 advanced template

I have created a cron job in console/controllers/

And the content of my action for the cron job is to send an email whenever it is executed and update some information in the database that matches some requirement.

It DOES work if I go manually to the root of the application and type:

php yii cron/action-name

However, when I try to run it from the cron configuration from VestaCP it does not work correctly (email is not being send and database is not updated).

Here is the cron command from VestaCP:

sudo php /home/user/web/ cron/action-name

I tried to run this cron every minute(* * * * )/five(/5 * * * *), etc - none helps.

However, if I try to execute this command manually from console — then it works perfectly.

Does anyone have an idea what can be the problem?

Not sure if this is related to Yii at all, but maybe someone has crossed this problem.

Okay, my problem was solved after a few minutes after I posted this post.

The "sudo" word was causing the problem. After I deleted it from the command, the cron job executing correctly.