I'm running a Python script on AWS (Amazon Linux AMI). The script is meant to run 24/7 and prints out to the interpreter or command terminal.
It's still in development, so I like to check to see how it's behaving or if it's stopped due to an error. But, I want to be able to close my ssh connection or turn off my local machine without interrupting the script, and then ssh back in and see it in real-time.
First I used:
[[email protected] dir]$ nohup python3 myscript.py &
That worked fine for closing the ssh connection, coming back in, and seeing that it was still running, and then writing all the print statements to nohup.out.
Is there a way for me to bring this to the foreground and see the print statements in real-time, and then send it back to the background to disconnect from ssh without interrupting the program?
The code has the general form:
import time
count = 0
while count < 100000:
print('Im working!')
time.sleep(10)
count += 1
print('All finished')