DEV Community

Cormac
Cormac

Posted on

1 1

How to Reconnect to Process logs on Ubuntu

Running continuous processes or functions on a virtual machine is essential for any large development process.

Here's how to continuously run a process on Ubuntu, disconnect and then reconnect to access a process' logs.

Step 1) Start 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

Screen User Manual

Step 2) Run your program with &

I'm running a validator in a GCP ubuntu virtual machine so my start command looks like:
sudo mortar server --data-dir ./data-dir --chain genesis.json --libp2p 0.0.0.0:1478 --nat IP-ADDRESS --seal --price-limit 1 &

Just make sure to add & to the end of whatever command you use. This is let the program to keep running even after you quit the shell session.

Step 3) Disconnect your SSH session

You can do this by closing the shell window

Step 4) Reconnect

Resume screen session: screen -r

You should now see the output of the process logs in real time

Billboard image

Deploy and scale your apps on AWS and GCP with a world class developer experience

Coherence makes it easy to set up and maintain cloud infrastructure. Harness the extensibility, compliance and cost efficiency of the cloud.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay