up vote 1 down vote favorite
share [g+] share [fb]

How do you make the escaping work so that the & is actually running the first command in the background?

# foo param1 param2 >> run.out &; tail -f run.out
link|improve this question

feedback

4 Answers

up vote 7 down vote accepted

Just drop the semicolon:

# foo param1 param2 >> run.out & tail -f run.out
link|improve this answer
2  
It helps to think of the ampersand as a variant of the semicolon, which it is, really. – Teddy Oct 7 '09 at 4:52
feedback

You could use nohup:

nohup cmd & 

tail -f nohup.out
link|improve this answer
feedback

You need to put the backgrounded command in ()'s.

(ls -R / >>/tmp/list & ); tail -f /tmp/list

Sadly, this really backgrounds it. You won't be able to us %1 to get to its PID.

link|improve this answer
feedback

I just ran into this question as well, and solved it this way:

`foo param1 param2 >> run.out &` ; tail -f run.out

I don't know if the semantics are different.

For this specific case, the following is also useful:

foo param1 param2 | tee -a run.out
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.