Bash – pipe many outputs to same file at the same time

bashshell

Say i have a bash script:

#!/bin/bash
php ./listen.php 3001 3003 26 &
php ./listen.php 3002 3004 120 &

can i pipe all of them to same output log file at the same time without conflict?
example:

#!/bin/bash
php ./listen.php 3001 3003 26 >/tmp/log 2>&1 &
php ./listen.php 3002 3004 120 >/tmp/log 2>&1 &

Best Solution

> overwrites, so you'll want >> instead. stdout is line-buffered by default, so that is relatively safe. stderr is not. You should consider writing to the system log instead though.