Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

3 Answers 3

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
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
add comment

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

share|improve this answer
add comment

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
add comment

Your Answer

 
discard

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.