Skip to main content

Disowning your children (in bash/zsh)

You learn something new every day!

Today I learned about the disown builtin in bash and zsh. When you disown a job, it will no longer receive a HUP signal when you exit your shell.

[email protected]:~ [1015]% while true; do date >> date.log; sleep 10; done&

[1] 7380

So now you've got the current date being appended to date.log every 10 seconds.

Try exiting your shell:

[email protected]:~ [1016%1]% exit

zsh: you have running jobs.

But use the disown command:

[email protected]:~ [1017%1]% disown %1

[email protected]:~ [1018]% exit

and your shell exits without complaining. Meanwhile, your job keeps running in the background!