Ive seen tons of examples where a & follows the end of a command string, but I can't seem to find an explanation on what it does. It's not even in nohup's man page. Is this a shell thing?

Either using & or not, I find that any process ran with nohup seems to exhibit immunity to any hangup signal.

  • 1
    "I find that any process ran with nohup seems to exhibit immunity to any hangup signal." That's what nohup is for. – Samuel Edwin Ward Jun 26 '12 at 20:53
  • Ok, so let me clarify: the only examples I've seen uses the &, so I wasn't sure if & was some sort of modifier or arguement that made nohup behave any differently. – Chad Harrison Jun 26 '12 at 21:04
  • 1
    That's a reasonable thing to suspect. In fact it doesn't modify the behaviour nohup (nohup doesn't even get to see it) but modifies the behaviour of the shell. – Samuel Edwin Ward Jun 26 '12 at 22:41
  • nohup& -> No Hangup and background it. From the good old days of modems and serial terminals. When my terminal and modem go offline, keep processing this in the background so the job's done when I next go online. – Fiasco Labs Jul 9 '13 at 17:24

From the bash manpage:

If a command is terminated by the control operator &, the shell executes the command in the background in a subshell. The shell does not wait for the command to finish, and the return status is 0.

So yes, it's a shell thing, and can be used with any command. It essentially returns control to you immediately and allows the command to complete in the background. This is almost always used with nohup because you typically want to exit the shell after starting the command.

  • 4
    I've seen you post a bunch of good answers lately and my brain always translates your username to McGuyver. Not sure why I feel the need to tell you this. – MDMarra Jun 26 '12 at 20:54
  • 1
    @MDMarra I'll take that as a compliment ;-) – mgorven Jun 26 '12 at 20:56
  • 1
    @MDMarra At least you don't think: "McGruber" – Ward - Reinstate Monica Jun 26 '12 at 20:58

Using the ampersand (&) will run the command in a child process (child to the current bash session). However, when you exit the session, all child processes will be killed.

using nohup + ampersand (&) will do the same thing, except that when the session ends, the parent of the child process will be changed to "1" which is the "init" process, thus preserving the child from being killed.


Yes, it's a shell thing--it runs the command in the background so you don't have to wait for the current command to return before issuing more commands.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.