ShanZhengYang
ShanZhengYang

Reputation: 17651

Running a Python job remotely with ssh---how can I log out?

I am running a Python script filename.py via ssh. Once I'm logged into the remote machine, I run:

python filename.py &

However, when I close out of the terminal, it appears the python stops running. Why is this? I thought an ampersand & at the end of a statement meant the program kept running?

Upvotes: 3

Views: 832

Answers (2)

Alex Woolford
Alex Woolford

Reputation: 4563

Use nohup:

nohup python filename.py &

nohup [command] & will run the job in the background and return you back to the shell.

Upvotes: 6

Daniel Mizerski
Daniel Mizerski

Reputation: 1131

I am not so far into python in shell, but you can use screen in ssh related enviroments

For example:

sudo apt-get install screen

screen -m

This will create virual tty (pty)

Then run your program

python prog.py &

Hope it will work fine for you, have a nice day!

Upvotes: 2

Related Questions