• TimTamJimJam@lemmy.world
    link
    fedilink
    arrow-up
    118
    ·
    8 months ago

    Happened to me in work once… I was connected via SSH to one of our test machines, so I could test connection disruption handling on a product we had installed.

    I had a script that added iptables rules to block all ports for 30 seconds then unblock them. Of course I didn’t add an exception for port 22, and I didn’t run it with nohup, so when I ran the script it blocked the ports, which locked me out of SSH access, and the script stopped running when the SSH session ended so never unblocked the ports. I just sat there in awe of my stupidity.

        • u/lukmly013 💾 (lemmy.sdf.org)@lemmy.sdf.org
          link
          fedilink
          English
          arrow-up
          10
          ·
          edit-2
          8 months ago

          Well, the script could keep running even after he would have detached from that tmux session due to losing ssh connection. And since that script would unblock all ports after 30 seconds…

          (Same use case as nohup that they mentioned)

        • JasonDJ@lemmy.zip
          link
          fedilink
          arrow-up
          3
          ·
          7 months ago

          Tmux essentially creates a pseudo-shell that persists between sessions.

          So you can start a process, detach the session, start something else, disconnect, come back next week, and check on it.

          It does other things too. Like console tiling.

    • krash@lemmy.ml
      link
      fedilink
      arrow-up
      3
      ·
      7 months ago

      Out of curiousity, how would nohup make your situation different? As I understand, nohup makes it possible to keep terminal applications running even when the terminal session has ended.

      • octopus_ink@lemmy.ml
        link
        fedilink
        English
        arrow-up
        7
        ·
        7 months ago

        If the script was supposed to wait 30 secs and then unblock the ports, running with nohup would have allowed the ports to be unblocked 30 secs later. Instead, the script terminated when the SSH session died, and never executed the countdown nor unblock.

      • aidan@lemmy.world
        link
        fedilink
        arrow-up
        5
        ·
        7 months ago

        the script stopped running when the SSH session ended so never unblocked the ports