Let's say I have this python script on my VPS:
# test.py
import time
while True:
print('tick...')
time.sleep(10)
If I log into my VPS using SSH and run this script, I can see tick...
messages appearing in the console. But if I log out and log in again, everything is gone. I can see using htop
that the python script is still running, just not printing anything into my new SSH session.
Is there any way I can recover the last SSH session, so I can see the results of my script again?
I tried the screen
tool (screen -S test
-> python test.py
), but after re-connecting to SSH, when I try to go to my screen session (screen - S test
) it only prints [screen is terminating]
.
screen -S test
multiple times will result in multiple sessions, seescreen -ls
to list all sessions.screen -S test
the second time, butscreen - S test
(space between minus and S). This command is incorrect and screen is immediately returning.-
andS
when writing to the terminal.