Quickie Unix Tip: disown – a shell builtin for bash and zsh
Here’s a useful little tip I picked up this week courtesy of this great thread on reddit: the ‘disown’ shell builtin. Here are the details from the bash man page:
disown [-ar] [-h] [jobspec ...]
Without options, each jobspec is removed from the table of
active jobs. If jobspec is not present, and neither -a nor -r
is supplied, the shell's notion of the current job is used. If
the -h option is given, each jobspec is not removed from the ta-
ble, but is marked so that SIGHUP is not sent to the job if the
shell receives a SIGHUP. If no jobspec is present, and neither
the -a nor the -r option is supplied, the current job is used.
If no jobspec is supplied, the -a option means to remove or mark
all jobs; the -r option without a jobspec argument restricts
operation to running jobs. The return value is 0 unless a job-
spec does not specify a valid job.
In a nutshell that means if you have a background process that you’ve started from your shell and you’d like it to keep going when you log out (intentionally or not!), all you’ve got to do is type: ‘disown %1′ and that job will keep going after you’re gone. That’s a trick I wish I knew years ago!