Invoke a command immune to hangups (POSIX)
nohup command
The nohup utility invokes the specified command. When the command is invoked, the SIGHUP signal is set to be ignored; thus, the command is made immune to hangups.
If the standard output is a terminal, all output written by the specified command to its standard output is appended to the nohup.out file in the current directory. If this nohup.out file can't be created, or if it can't be opened for appending, the output is appended to the end of the nohup.out file in the directory specified by the HOME environment variable. If neither nohup.out file can be created or opened, the specified command isn't invoked.
If the standard error output is a terminal, all output written by the specified command to its standard error output is redirected to the same file descriptor as the standard output.
It's often desirable to apply nohup to pipelines or lists of commands. You can do this by placing pipelines and command lists in a single file; this file can then be executed as a command, and the "nohup" applies to everything in the file.
Alternatively, the following can be used to apply nohup to a complex command:
nohup sh -c 'complex-command-line'
Similarly, you can use the following commands to apply nohup to a shell function:
export -f func nohup sh -c 'command line invoking func'
If you want the SIGQUIT signal to also be ignored, you can run nohup in the background:
nohup command &
The exit status of nohup cannot be relied upon.