[LINUX] That ... can't you see the process you're running? The reason for

Introduction

You can borrow VPS with ConohaVPS etc. and access it with SSH from VS Code etc. of your own PC. At this time, the VS Code terminal and shell will be connected to the VPS terminal via the Internet.

At this time, for example

$ nohup python main.py &

By using the nohup command of, you can execute the process in the background of VPS and continue the process even if you close the terminal on the VS Code side.

Before closing the VS Code side

$ ps

You can see that python is running with the ps command.

problem

After closing the terminal on the VS Code side, if you reconnect to VPS

$ ps
  PID TTY          TIME CMD
28883 pts/0    00:00:00 bash
29006 pts/0    00:00:00 ps

As mentioned above, the Python execution command has disappeared ... At this time, I thought, "Because I closed the terminal, the process goes down even with the nohup command ..."> <

Cause

Since the terminal on the VS Code side is newly opened, only the processes generated from the shell of this new terminal will be displayed by the command of ps alone. Therefore, the process that was executing nohup on the closed terminal was executed with the terminal lost and was not displayed in ps.

$ ps aux

When you hit

--a Show processes of users other than yourself --x Display processes other than the current terminal --u Display in user format

And more detailed information will be displayed.

$ ps aux | grep python
root       652  0.0  0.0 267080     4 ?        Ssl  Apr16   0:00 /usr/libexec/platform-python -s /usr/sbin/firewalld --nofork --nopid
root       952  0.0  0.0 424304   280 ?        Ssl  Apr16   0:09 /usr/libexec/platform-python -Es /usr/sbin/tuned -l -P
root     28572 31.3 32.7 538180 160184 ?       R    07:47  17:45 python make_plot_chart_about_fail.py
root     28989  0.0  0.1  12108   972 pts/0    R+   08:43   0:00 grep --color=auto python

As mentioned above, when I ran python in the case of aux, I was doing my best while the python command properly lost the terminal in the background > < Thank you ... Thank you ... (Hiroshi Fujioka)

Summary

--ps aux has more information (sometimes when you want to know other processes or detailed information) --Let's get more knowledge of Linux ...!

References

Recommended Posts

That ... can't you see the process you're running? The reason for
What to do when you get "I can't see the site !!!!"
Thank you for the Fibonacci sequence.
See python for the first time
If you feel that you can't find the Object Inspector in recent Spyder
Qiita's first post (the reason for starting)
I see, I will read the UNIX process
Solution to the problem that you can't activate by putting conda in pyenv