Asynchronous calls in shell script

I was looking for a solution to invoke a php script in parallel and thereby causing multiple processes (simulating a load test). Calling the php in the shell one after the other would lead a synchronous route, i.e. the next execution won’t begin before the first one stops. Found this interesting solution that did the trick. I could also add in a little delay between two consecutive executions:

php /home/varun.verma/scripts/php/executeJob.php &
sleep 5
php /home/varun.verma/scripts/php/executeJob.php &
sleep 5
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s