1

I want to run script in background and write it output to log:

Here is my original script:

for i in `seq 1 3`; do ./script.sh $i &> "my_logs/"$i".log"; done

What I have tried:

for i in `seq 1 3`; do ./script.sh $i &> "my_logs/"$i".log" &; done

What is a proper way to do this?

for i in `seq 1 3`; do ./script.sh $i & &> "my_logs/"$i".log"; done
1
  • What is wrong with your attempt? (Aside from the unnecessary leaving-out of $i from the quotes: "my_logs/$i.log" is fine.) Commented Mar 1, 2017 at 15:10

1 Answer 1

1

I think you want:

for i in `seq 1 3`; do ./script.sh $i > "my_logs/$i.log"; done &
Sign up to request clarification or add additional context in comments.

1 Comment

I need each ./script.sh to be runned as separate background process and this seems just run for loop in background?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.