I
I
Igor Koltun2017-09-07 14:26:29
linux
Igor Koltun, 2017-09-07 14:26:29

How to make yii2 console command work all the time in Ubuntu Server?

In an application developed on the PHP yii2 framework, it is required to ensure the constant operation of the console command (WebSocket connection) - both starting when the server is restarted, and resuming work if the connection (command operation) has fallen off for some reason.
In manual mode, running a command looks like this:
cd /var/www/project
./yii example/command
If you exit the console (or ctrl + z), the command stops running.
How to do it right?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
matperez, 2017-09-07
@matperez

nohup ./yii example/command 2>&1 &

V
Vladimir Mukovoz, 2017-09-07
@castomi

Liked the solution above. + you can also add screen and, of course, daemonization. This is a more correct approach.

F
Fortop, 2017-09-07
@Fortop

The most convenient way to do this is with supervisord
. But for special cases, it can be redundant.

I
Igor Koltun, 2017-09-14
@3579km

Set up a daemon using supervisord.org (it's convenient to monitor the process from the web panel: status, restart, uptime)
Command executed by supervisord: nohup ./yii example/command 2>&1 &
Thanks everyone for the comments.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question