4

I need to test some locking in my PHP script and need to run it many times at the same time.

I remember I found a simple command to do that some time ago when I was testing MySQL locking, but can't remember the function and can't find it again. I'm running Ubuntu Linux 14.04.1.

I'm looking for a simple command without any loops.

Thanks.

7
  • I believe & will do the trick. Did you try php script1.php & php script1.php & php script1.php ? Commented Jul 14, 2015 at 18:14
  • the problem is i need to run it at least 50 times and later maybe 1000 times, that's why that won't work but thanks for a suggestion. Commented Jul 14, 2015 at 18:33
  • 2
    possible duplicate of How to make a bash script that creates 40 simultaneous instances of a program? Commented Jul 14, 2015 at 18:39
  • I tried using & to run 50 but it didn't run a most of them. Commented Jul 14, 2015 at 18:50
  • Karl, I've seen a couple of those, but there's some simple command without any loops. Commented Jul 14, 2015 at 18:56

2 Answers 2

6

Use AB testing in 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 do 5 concurrent processes

if you want to automate it to happen on its own activate a curl in a cron job

45 11 * * * /usr/bin/curl -G 127.0.0.1/yourscript.php >/dev/null 2>&1

this will run it every day at 11 45 am

See this page for more details about AB testing or benchmark testing in linux

Linux Benchmarking

Sign up to request clarification or add additional context in comments.

1 Comment

to add it to a cron job type in : EDITOR=nano crontab -e into your command line and then add that there and save it.
1

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 instance, this:

cmd="ls"; for i in $(seq 5); do $cmd; sleep 1; done

will list files in the current directory 5 times with one second in between.

Change the command to execute the script you need to, and change the $(seq 5) to how ever many times you want to run the command.

e.g

cmd="php my_script.php"; for i in $(seq 1000); do $cmd; sleep 1; done

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.