How to: Launch a Process that Persists even if you Disconnect your ssh Terminal
How to: Launch a Process that Persists even if you Disconnect your SSH Terminal
I’m not sure if this has happened to you before, but there are times when you have an application you wish to launch but if you disconnect from the terminal (SSH or physical) that process gets terminated. For example, currently I am running a proxy application that displays to the screen the status (connections to the upstream servers, work load, connection to the downstream clients, etc.). I want to be able to disconnect without causing it to be shut off. In order to achieve this, I am looking at using a terminal multiplexer. What this does is ti allows a user to access multiple separate terminal sessions inside a single terminal windows (physi8cal or remote like SSH.) This opens a new set of possibilities. If you are like me and sometimes end up with several SSH connections to the same server so you can observe different logs (thinking of tail -f) then what a multiplexer gives you is the ability to do so all in one connection. Thus far my favourite multiplexer is screen which comes built in with Ubuntu. Below I’ll get into the details on how to use it:
Screen is a terminal multiplexer, which allows a user to access multiple separate terminal sessions inside a single terminal window or remote terminal session (such as when using SSH).
Installation
The screen package can be installed on Ubuntu using apt-get or any other method you prefer. As far as I know it already comes installed with the latest versions (at least I haven’t needed to install it for some reason)
Starting with the Jaunty release, the screen-profiles package (later renamed Byobu) provides advanced features such as status bars, clocks, and notifiers. The package can also be manually installed on previous Ubuntu releases.
Usage
Screen can be started by typing
screen
in a terminal. Press Enter after reading the introductory text.
Virtual terminals in Screen can be manipulated by pressing the Ctrl+A key combination, and subsequently pressing a key to execute one of the commands given below:
-
c creates a new virtual console
-
n switches to the next available virtual console
-
p switches back to the previous virtual console
-
“ lists all available virtual consoles and their assigned numbers
- hitting a number key brings the corresponding virtual console to the foreground
-
Esc lets you scroll back and forth in your terminal output
-
d detaches the current screen sessions and brings you back to the normal terminal
When a Screen session is detached, the processes that were running inside it aren’t stopped. You can re-attach a detached session by typing
screen -r
in a terminal
To remove the annoying copyright notice at startup, edit your /etc/screenrc with
gksudo gedit /etc/screenrc
and remove the hash which begins the line
#startup_message off
Save the file, and you will not see it again
For further information and more advanced commands, you can refer to the screen man page.
Love
Can we use Let's Encrypt, the free and open certificate authority?
Hola! gracias por la info, me sirvió el comando sacandole el nombre del server. En mi caso, fue una migración…
Yes 3rd option helped me too. I removed the WC key Values from config file then started working.
I know this is from 2014. But really, thank you!