Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Why do I receive a bash syntax error when amending output >> to a file from a nohup command?

# sudo nohup php something.php &>>/tmp/output
-bash: syntax error near unexpected token `>'

I'm using red hat enterprise

share|improve this question
&>> is a bash-4-ism to append both stdout and stderr to a file. Older versions of bash and other shells do not have this. – DerfK Oct 25 '11 at 20:45
up vote 0 down vote accepted

There's no reason to do that. When you "nohup" a command and BG it, output will automatically be redirected to $HOME/nohup.out. Even if it did work, you'd likely wind up with an empty file.

share|improve this answer
I need to direct the output to a particular file, not $HOME/nohup.out – user784637 Oct 25 '11 at 18:30
In that case, do nohup mycommand >> output.file & <-- this will run the entire command, which is both the "mycommand" and the output to the file, and then BG it with & – sandroid Oct 25 '11 at 18:33

Remove the &, just use >> to amend to /tmp/output

share|improve this answer

For bash &>file or &>>file means redirect both stdout and stderr to file. If you want put something to background, put an & as last character in the command line, after any possible redirection.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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