Running Commandline Action "repeatedly"


I wrote a Command Controller, that runs some background work for our application. The action is started every minute using a cronjob.

This works fine so long…


Now I have two more requirements for this action:

1.) Now the action should not run every minute… It should run "repeatedly", so when it is ready, it should start over.

2.) The action is only allowed to run once at a time, so if the action is currently running, it should not run again.

How can I solve this using yii2, cronjobs and my command controller?

Thanks for your help,


You should meet mutex ( ).

It’s a nice guy that’s willing to help you for this requirement :D