Tuesday 30 April 2019

process - quit tmux server and end all running processes


I am running a tmux server configured by tmuxinator. In one pane my django server is running:


python manage.py run_gunicorn

If i quit tmux by calling the kill-server command, the run_gunicorn command is not killed as i would have expected, but is sent to the background:


$ ps aux | grep gunicorn 
alp 3358 1.0 0.1 126988 21728 ? S 13:06 0:00 python manage.py run_gunicorn

How can i quit the tmux server while quiting all running processes within?



Answer



I have found an alternative by adding a line to my tmuxinator config:


pre: pkill -f "^python manage.py run_gunicorn"

The ^ at the beginning only matches processes which are starting with that command. Without it you would also kill the tmux process as well.


This does not solve the problem with remaining background processes, but it kills any old processes when restarting the tmux session, which is an acceptable workaround in my case.


No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...