3

I need to run a python code that takes several hours and my computer disconnects from the ssh after a certain amount of inactive time.

I have tried python test.py> output.txt & but my output file is empty. However, the python code "test" is still running after I log off and log back in to the ssh. I also tried python -u test.py> output.txt & which does write to the output.txt but it does not continue after the ssh connection is lost.

I am very new to Linux so I do not know very many commands. I need the simplest/easiest to understand method. Thanks!

asked Oct 24, 2013 at 23:15

3 Answers 3

2

You can use screen, as Robin Krahl recommended, or you can just run your command with nohup, which suppresses the SIGHUP (hangup) signal from your SSH session disconnecting.

nohup "python -u test.py > output.txt" &

answered Oct 24, 2013 at 23:20
Sign up to request clarification or add additional context in comments.

Comments

1

screen is the tool you want to use.

answered Oct 24, 2013 at 23:17

Comments

1

As others have said, screen is what you want. tmux is newer? tool that does the same thing, and byobu is an easy-to-use wrapper for both.

answered Oct 24, 2013 at 23:26

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.