Skip to main content
It wouldn't help if it was a builtin: builtins have an ordinary syntax. To support a subshell “argument”, nohup would have to be a keyword, like time.
Source Link
Gilles 'SO- stop being evil'
  • 865.4k
  • 205
  • 1.8k
  • 2.3k

The nohup command is not a builtina keyword; it can't be given a subshell as the command to run, and instead it requires an actual runnable command:

nohup bash -c 'sleep 120; echo "job done"' &

Bash is giving you a syntax error because it thinks you're trying to declare a function called "nohup", which is the only case where a bare parenthesis can appear in the second word on the command line:

nohup () { ... ; }

The error message is telling you (obscurely) that it expected to see the right parenthesis there and not the word "sleep".

The nohup command is not a builtin; it can't be given a subshell as the command to run, and instead it requires an actual runnable command:

nohup bash -c 'sleep 120; echo "job done"' &

Bash is giving you a syntax error because it thinks you're trying to declare a function called "nohup", which is the only case where a bare parenthesis can appear in the second word on the command line:

nohup () { ... ; }

The error message is telling you (obscurely) that it expected to see the right parenthesis there and not the word "sleep".

The nohup command is not a keyword; it can't be given a subshell as the command to run, and instead it requires an actual runnable command:

nohup bash -c 'sleep 120; echo "job done"' &

Bash is giving you a syntax error because it thinks you're trying to declare a function called "nohup", which is the only case where a bare parenthesis can appear in the second word on the command line:

nohup () { ... ; }

The error message is telling you (obscurely) that it expected to see the right parenthesis there and not the word "sleep".

Source Link
Michael Homer
  • 78.9k
  • 17
  • 221
  • 239

The nohup command is not a builtin; it can't be given a subshell as the command to run, and instead it requires an actual runnable command:

nohup bash -c 'sleep 120; echo "job done"' &

Bash is giving you a syntax error because it thinks you're trying to declare a function called "nohup", which is the only case where a bare parenthesis can appear in the second word on the command line:

nohup () { ... ; }

The error message is telling you (obscurely) that it expected to see the right parenthesis there and not the word "sleep".