18.01.2020 Views

Working with Linux

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

our initial session if we want to. To detach (leave a session running and go back to the normal

terminal) hit Ctrl + b d;

Now we can see we have two opened sessions.

To attach to a session:

tmux a -t mysession

This scenario comes in handy when you login to a remote server and want to execute a long running

task, then leave and come back when it ends. We will replicate this scenario with a quick script

called infinity.sh. We will execute it. It's writing to the standard output. Now let's detach from tmux.

If we look at the script, it's just a simple while loop that goes on forever, printing text each second.

Now when we come back to our session, we can see the script was running while we were detached

from the session and it's still outputting data to the console. I will manually stop it by hitting Ctrl + c.

Alright, let's go to our first tmux session and close it. In order to manually kill a running tmux session,

use:

tmux kill-session -t mysession

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!