0

haven't used nohup command until today, but now I need to use it to run a command in the background.

As far as i know, i can also use the bg command to run a process in background. So my question is, what are the differences between nohup and bg commands?

3

1 Answer 1

1

Running a command in the background allows you working on in that shell, but does NOT prevent the command from being killed once you exit the session (e.g. log out from the desktop session, end an ssh-session, exit the tty).

nohup is meant for starting long-running processes that should run on a server even when the user logs out.

1
  • 2
    To add to this, nohup is short for no hang up which prevents the process from receiving the SIGHUP or Signal Hang UP signal -- which is the signal sent when closing/exiting the terminal.
    – clownbaby
    Commented Feb 12, 2021 at 0:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .