I have a remote Linux server. How do I keep a python script running after I exit the SSH…
- User
I have a remote Linux server. How do I keep a python script running after I exit the SSH session?
- Assistant
You can keep a Python script running after you exit the SSH session on a remote Linux server by using the
nohupcommand followed by the script command.Here's an example of how you can do this:
- SSH into your remote Linux server.
- Run the following command to start your Python script and run it in the background:
codenohup python your_script.py &Replace
your_script.pywith the name of your Python script.-
After running the command, you should see a message like
nohup: ignoring input and redirecting stderr to stdoutwhich indicates that the script is running in the background. -
You can now exit the SSH session by typing
exitand pressing Enter.
Your Python script should continue running even after you exit the SSH session. You can check the status of your script using tools like
psortopto see if it is running.