sr320 / course-fish546-2016

6 stars 5 forks source link

Remote machines #74

Closed sr320 closed 7 years ago

sr320 commented 7 years ago

What is the difference between nohup and tmux. Which one would you be more likely to use and why?

mfisher5 commented 7 years ago

nohup catches and ignores hangup signals. Hangup signals terminate any running processes and applications when network connections temporarily drop out, or if you disconnect from your server. By ignoring the hangup signals, nohup allows the program to keep running.
tmux doesn't just allow you to keep your program running if your connection drops, it also keeps the program running when you close or quit the terminal. tmux does this by creating a "session" with multiple windows, which can all be restored by "reattaching" the session.
Since I'm working with multiple runs of the same program to test parameters, it would be better to be able to open multiple windows within one session. I also don't want to have to keep the terminal window open for the entire time the process is running (which can take ~12 hours for certain parts of the stacks pipeline). So I would probably be more likely to use tmux.

yaaminiv commented 7 years ago

When appended to the beginning of a command, nohup catches hangup signals. The only way the process can be terminated is if you close the terminal, or terminate the process ID. tmux allows you to attach and reattach sessions without losing work, allowing the user to run programs if the connection drops or if terminal is closed.

I'm more likely to use nohup because my workflow doesn't involve running several scrips simultaneously, so I have no need to open multiple windows at once. But I'd rather use the Mac Screen Sharing application to run commands on the lab computer instead of having to do any of it from the command line :sunglasses:

Ellior2 commented 7 years ago

Nohup is a simple command that will catch and ignore hangup signals allowing your session to be uninterrupted when a connection drops or you accidently close your terminal.

tmux allows you to run multiple sessions at the same time. Within each session you can have multiple windows. It also allows you to detach and reattach your sessions without losing work. When tmux is run on a remote machine you can maintain a session even if the connection is lost or you move to a new terminal- just SSH back into your remote host and reattach.

At this point I might start out using nohup due to it's simplicity, but eventually it may be advantageous to multi-task and run several projects at the same time using tmux.

nclowell commented 7 years ago

nohup is a command that prevents hang ups. Syntax-wise, nohup is very simple -- you simply add the text nohup at the beginning of the line and add the rest of your commands as usual. You can terminate with the process ID that nohup returns.

tmux is a more complex command that allows you to multiplex your process (run multiple sessions that can have multiple windows). It prevents hang ups by detaching and reattaching your sessions, and preserving progress. If the connection is lost while using tmux on a remote machine, you can simply reattach the session(s) and it will appear to be still running.

Given that my brain can't even come up with a way that I could take advantage of tmux, I suspect I'll only be using nohup in the near-future!

laurahspencer commented 7 years ago

nohup (for no hang-up) catches and ignores hangup signals sent from the terminal, thus allowing the a program to continue running without interruption. nohup is simple, and can be included before running any program command, and it provides a process ID number to control/terminate later.

tmux (for terminal multiplexer) allows for multiple sessions, multiple processes/windows within a session, that won't be terminated if you lose connection or the terminal closes. tmux sessions. tmux sessions can be detached and reattached without losing any work.

At this point, since I'm not using a remote server and my programs/processes are very simple, I'm more comfortable using nohup. I could see incorporating tmux into my workflow in the future when I'm working with much larger datasets.

aspanjer commented 7 years ago

nohup and thux both allow you to run scripts on a remote machine without fear of interruption due to a lost connection. the nohup command is simple to use by including before the rest of the command you enter, providing the user with a process ID that allows you to find the process should your connection drop. tmux is essentially the same thing, but has an added benefit as a "terminal multiplexer" that allows you to run multiple windows (processes) under a single session. Should your connection drop, all of these windows can be recalled with a single session ID.

tmux would be really useful, as I find that I run multiple processes. As I wait for one analysis to finish on multiple files, I often begin running the next step in a new terminal window on the files that are already completed.

jldimond commented 7 years ago

nohup and tmux similarly allow you to protect your commands from stopping by preventing hangups. With both you can log out of your ssh session and the processes will keep running. With nohup you can close the Terminal window, and with tmux you can even quit Terminal. tmux adds the ability to run multiple processes at once. I would probably use nohup more often than tmux, and should make a better habit of doing this.

mmiddleton commented 7 years ago

nohup catches hangup signals so that processes running in the terminal are not stopped in the event a connection drops or the terminal window is closed. Once the nohup command is added to a process it can only be terminated using the process ID that is returned once the process is started. tmux catches hangup signals as well, but it also allows for greater productivity by allowing you to have multiple windows which each run their own process.

I would probably be more likely to use nohup since I'm not quite to the point where I need to have that many processes going at once. However, the ability to quit the terminal program entirely with tmux and still keep your processes running is appealing because I'm prone to quitting programs when I think that I'm done with them.

MeganEDuffy commented 7 years ago

Both nohup and tmux are commands that can help you run time-intensive processes without fear of them terminating if disconnected from a server, i.e., because of a hangup signal (SIGHUP).

nohup is a command that sees and ignore a SIGHUP, so applications continue to run if connection to the network or remote machine is lost (or if the terminal is closed). When you usenohup , simply by adding it before running a process, it returns a process ID number that you can use to monitor and terminate a process if need be.

tmux is different from nohup in that it is a terminal multiplexer. This means that the user can generate as many windows as needed, each of which is running its own process. What's more, these processes won't be terminated if the terminal application is ended, or if connect to remote machines is lost. The session, a separate environment with all its windows, can be restored for viewing with all processes still running uninterrupted.

I think I am more likely to use tmux. It seems like it's definitely a little more challenging to get a handle of, but that it's incredibly powerful. In the future I think I'll do more work on a cluster and I'm not sure it already has software that we would use for time-intensive jobs. Also I want to use Amazon Web Services to rent machines for running the Trans-Proteomic Pipeline. I'm not totally sure if tmuxis useful for this, but I think it could be (according to this tmux praising blog post).