I am trying to test the nohup command in the bash shell by executing a command in the background and logging out and back in again and expecting the output of the command to be in the nohup.out file. Here is the command I am trying to execute:

$ nohup (sleep 120; echo "job done") &

But I keep getting the error:

bash: syntax error near unexpected token `sleep`
  • 2
    Remove the subshell
    – jesse_b
    Mar 3, 2018 at 20:21

1 Answer 1


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".

You must log in to answer this question.

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