D
D
Denis Sh.2018-03-26 18:30:19
Yii
Denis Sh., 2018-03-26 18:30:19

How to determine if the execution of the console command has completed?

There is a project on Yii 2 and several console commands hung on kroner. Some run once a minute, some once every half an hour. How can I find out if this or that command has been executed and if not, then do not run it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Lykasov, 2018-03-26
@DShcherbakov

The easiest way is to use lock files. When run, the command creates an empty file with a specific name, and deletes it when finished. Accordingly, at startup, it checks whether such a file already exists, and if it does, it means with a high degree of probability that the previous launch is still working. Instead of a file, it is fashionable to use a database.
A more complicated way is to run tasks through a special task manager that will monitor their order, control whether the process has hung, etc.

V
vksee, 2018-03-27
@vksee

There is a ready solution. You can use file locks, databases, etc.
https://www.yiiframework.com/doc/api/2.0/yii-mutex...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question