8

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

4 Answers4

16

Just drop the semicolon:

# foo param1 param2 >> run.out & tail -f run.out
katriel
  • 4,547
1

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.

TomOnTime
  • 8,381
0

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
0

You could use nohup:

nohup cmd & 

tail -f nohup.out
Stephan
  • 51