Run PHP script multiple times simultaneously with linux command line
I need to test for some blocking in my PHP script and need to run it many times at the same time.
I remember I found a simple command to do this a while ago when I was testing MySQL locking, but I can't remember the function and can't find it again. I am running Ubuntu Linux 14.04.1.
I'm looking for a simple command without any loops.
Thank.
source to share
Use AB Testing on Linux
run this command
ab -n 1000 -c 5 http://yourpage.php
where -n 1000 means 1000 times to run it
and where -c 5 means you are going to have 5 parallel processes
if you want to automate it so that it activates curl on its own in the cron job
45 11 * * * /usr/bin/curl -G 127.0.0.1/yourscript.php >/dev/null 2>&1
this will run every day at 11:45 am
See this page for more information on AB Testing or Benchmarking in Linux
source to share
You can use this command to run your script multiple times:
cmd="..some command..."; for i in $(seq 5); do $cmd; sleep 1; done
For example, this:
cmd="ls"; for i in $(seq 5); do $cmd; sleep 1; done
will display files in the current directory 5 times at one second intervals.
Change the command to execute the script you need and change $(seq 5)
to how many times you want the command to run.
eg
cmd="php my_script.php"; for i in $(seq 1000); do $cmd; sleep 1; done
source to share