Tmux
tmux is a terminal multiplexer. It lets you switch easily between several programs in one terminal, detach them (they keep running in the background) and reattach them to a different terminal. From getting started with tmux:
- A user connects to a remote server using ssh(1) from an xterm(1) on their work computer and run several programs. perhaps an editor, a compiler and a few shells.
- They work with these programs interactively, perhaps start compiling, then close the xterm(1) with tmux and go home for the day.
- They are then able to connect to the same remote server from home, attach to tmux, and continue from where they were previously.
Using Tmux as a process manager
Linux processes that are not associated with a TTY are said to be running in the background (of the shell) and most long-running services like a webserver, rely on systemd to manage them. While not hard, creating a systemctl file is tricky with respect to logging and file permissions.
As an alternative to formally daemonizing a process, one can simply run tmux, start a command line program in the shell and then detach from tmux. Any output from stdout will be stored in the FIFO associated with the shell. This affords the user an easy way to set logging limits and deal with output as they would with any CLI program.