I have a php file, called iter.php. I can easily run this from bash typing:
php iter.php >> result.txt
And I can run it multiple times in a row by just repeating it. However, I need to run them concurrently. So, in other words, if I run two instances in a row, they should finish at more or less the same time and output right after each other, as apposed to running right after each other.
Can I accomplish this in bash?
by using &
:
php iter.php >> result.txt & php iter.php >> result.txt
You can test this is working by
php iter.php >> result.txt & sleep 10000 & php iter.php >> result.txt
!#/bin/bash
seq $1 | while read num do
php iter.php >> $2 &
done
The above bash script should run $1
(first script parameter) processes conccurently, and output the result in $2
(second bash parameter).
Note that if your PHP script executes very quickly, you might actually not see the result of a concurrent run but instead a sequential one. It depends on whether:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.