this post was submitted on 16 Feb 2024
716 points (97.6% liked)

Programmer Humor

32479 readers
348 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 118 points 9 months ago (14 children)

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.

[–] [email protected] 11 points 9 months ago (3 children)

the script stopped running when the SSH session ended

tmux
Always use tmux when possible for remote connections.

[–] [email protected] 2 points 9 months ago (2 children)

What does it do in this case?

[–] [email protected] 10 points 9 months ago* (last edited 9 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)

[–] [email protected] 3 points 9 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.

load more comments (10 replies)