• Home

  • AWS FreePBX ▼

    • Online Demo
    • EC2 Deployment Guide
    • First Launch and Setup
    • Change Log
  • Support & Contact ▼

    • Support Wiki
    • Live Chat/Support Request ►
    • Support Types & Terms
    • Total Privacy Policy
  • Paid Support ▼

    • Paid Support Credits
    • Paid Support Plans (NEW!)
    • Paid Support Scheduler ◊
    • Paid Support Account ◊
  • Service Status ►

  • More ▼

    Use tab to navigate through the menu items.
    📢 START HERE: Introducing SmartUpgrade
    To see this working, head to your live site.
    • Categories
    • All Posts
    • My Posts
    TheWebMachine Networks
    Apr 16, 2020
    Edited: Apr 16, 2020

    tmux Can Save Your Sanity...and maybe your job!

    in AWS General

    Have you ever started running a long process in an SSH session on a cloud server and then spent the next hour hoping nothing happens to your internet connection or SSH session before it finishes the task? WE ALL HAVE and, as more and more of our most critical servers move to the cloud, this becomes an ever-increasing point of stress in your daily workflow. One of the most overlooked utilities in the BSD/Linux toolbox is one that has been around for over a decade, but is only now truly seeing its glory recognized in the cloud computing age...it could very well save your server (and maybe even your job)! We're talking about  tmux ; a Terminal Multiplexer. That may sound complicated, but the premise is simple: Treat Terminal (SSH) Sessions like individual "Panes" that aren't bound to an actual console. This not only means you can see and interact with multiple virtual terminals in a single SSH Client window, but this also means that your sessions are NOT LOST when you disconnect from the server!  NOTE: While tmux is immediately available on TWM-AMI v3.x, it is NOT pre-installed on TWM-AMI v2.x. If you are unable to run the tmux command, simply run the following to download, compile, and install tmux:


    SmartUpgrade install-tmux

    There's a TON that tmux can do and there are plenty of folks out there who have written lots of guides, tutorials, tips, even custom themes for tmux; but we're going to focus on how tmux can save you from disaster in the cloud. At its most basic, you can launch into a new tmux session by simply running:


    tmux

    That said, we'd recommend getting in the habit of launching in a way that will grab an existing session if one exists or create it if it doesn't. This is how we work with "persistent" sessions:


    tmux new -A -s 'MySession' 
    # You can put any identifying name/number you want instead of "MySession"; avoiding things like spaces and fancy characters

    Initially in tmux, it looks much like a normal terminal session, spare the addition of a green info bar at the bottom. You start in a single Pane. Most tmux commands are initiated with  Ctrl+b  followed by the command. To add additional Panes to your Session, use  Ctrl+b "  to split the Window horizontally or  Ctrl+b %  to split the Window vertically. You'll see a new terminal session launch in the new Pane. To switch between Panes in a Window, use  Ctrl+b  followed by an arrow key in the direction you want to move. To close the active Pane, use  Ctrl+b x  and then  y  to confirm the yellow info bar prompt. If you close a single remaining Pane, your entire tmux Session will be terminated and you will be dropped back to the normal prompt. Now, here's