Overview
nohup runs a command so that it ignores the hangup signal, the one a terminal sends when you close it or log out. The command keeps running in the background. If its output would go to the terminal, nohup redirects it to a file named nohup.out.
Background
The macOS manual says nohup is expected to be POSIX.2 compatible, and gives no date. Today the name covers GNU nohup, the nohup that macOS ships, and the nohup applet in BusyBox. They agree on ignoring the hangup signal and on the nohup.out default.
Examples
Run a command with nohup; here its output is not a terminal, so it is passed through:
nohup echo hi
Send the output to a file of your choice and read it afterwards:
nohup sh -c 'echo hi' > out.log 2>&1 && cat out.log
Start a long command in the background so it survives the terminal closing:
nohup sleep 1 > /dev/null 2>&1 & wait; echo started
Common mistakes
nohup does not put the command in the background; add & yourself. When both output streams go to the terminal, nohup.out appears in the current folder, which can surprise you. A command that is already stopped by a signal other than hangup is not helped by nohup. For long-lived services, a process supervisor or a terminal multiplexer such as tmux is a better choice.
Portability
Only running a command and redirecting its output are in the Common examples. The message nohup: ignoring input and its wording differ between implementations and go to standard error. The Common examples were executed on GNU coreutils 9.11, macOS system tools, and BusyBox 1.37.0 (see the development guide for the exact check).
About BusyBox nohup
BusyBox bundles nohup as an applet, and anything beyond the common options depends on how it was built. This page's examples ran on BusyBox 1.37.0.
BusyBox notes
BusyBox nohup supports the options used in the Common examples. Others, and GNU long options, depend on the build.
References
Original explanations, with upstream documentation for further reading. FreeBSD references are comparison material, not a claim of Apple version equivalence.