pythonlinuxubuntuterminate

How to restart specific running python file Ubuntu


I have running python file "cepusender/main.py" (and another python files). How can I restart/kill only main.py file?


Solution

  • Here's a way (there are many):

    ps -ef | grep 'cepusender/main.py' | grep -v grep | awk '{print $2}' | xargs kill
    

    Output now looks like the following:

    user      77864   68024  0 13:53 pts/4    00:00:00 python file.py