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

link|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
feedback

3 Answers

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.

link|improve this answer
I need to direct the output to a particular file, not $HOME/nohup.out – user784637 Oct 25 '11 at 18:30
2  
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
feedback

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

link|improve this answer
feedback

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.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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