Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

When do you need 'nohup' if you're already forking using '&'?

First this question is related but definitely not the same as this very nice question:

Difference between nohup, disown and &

I want to understand something: when I do '&', I'm forking right?

Is it ever useful to do "nohup ... &" or is simply & sufficient?

Could someone show a case where you'd be using '&' and still would want to use 'nohup'?
by

1 Answer

Bharatv4tg1
One thing I don't see mentioned here, the "send HUP on terminal exit" event is configurable - it may or may not happen. This may be confusing some peoples' perception of how nohup is working. If sending HUP on terminal exit has been disabled, they will come to the conclusion nohup is not needed. Sending HUP on terminal exit is a shell option in bash.

Try
shopt | grep huponexit

This will tell you if HUP is even being sent on terminal exit. If it is, you will need to use nohup. If it is not, you won't.

Login / Signup to Answer the Question.