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.

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
share|improve this question

4 Answers 4

up vote 10 down vote accepted

Just drop the semicolon:

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

You could use nohup:

nohup cmd & 

tail -f nohup.out
share|improve this answer

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.

share|improve this answer

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
share|improve this answer

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.