'Reattach shell session to process running on Ubuntu [closed]

I have an ongoing process running on a GCP vm. When initially start the program it spits our logs in real-time from the shell session, however when I exit the session and re-connect the next day the logs are gone.

How do I reconnect to the process to see the logs again in real-time?



Solution 1:[1]

Use the program screen

This might be already installed, check with:

screen --version

If not, install with one of these commands (OS specific)

yum install screen
apt install screen

Open a screen session

screen

Run your program. You can now disconnect your SSH session. Later you can reconnect using SSH and resume the running screen session:

screen -r

Screen User Manual

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 John Hanley