How to reopen a running .sh script in a new terminal in ubuntu

Issue

I’m running a headless linux server which I’ve ssh’d into. Now that only gives me 1 terminal to work with, and I can startup a minecraft server with a .sh script. But if I close that ssh terminal, how would I get access to the same .sh script that is still running in the background. Because if I reconnect with ssh again, it opens a fresh terminal.

Solution

You could use tmux.

When you ssh to the server for the first time, you could start a tmux session:

tmux

And then run your a.sh.

When you close the ssh terminal and reconnect with ssh again, you can attach the previous tmux session with:

tmux a -t 0

You could access to the same running .sh script

Answered By – ramsay

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published