0

If I execute a php file like such:

 php phpfiletoexecute.php

It will run 1 time.

What I would like to do, is run the php file example 5 times one after another (1st completes, 2nd run starts, 3rd, 4th, 5th, end)

What is the command to use?

4
  • 1
    for i in {1..5}; do php phpfiletoexecute.php; done
    – Tom Hunt
    Nov 19, 2015 at 15:48
  • do you care about the success of each run (to determine whether to run another time) - or just run 5 regardless?
    – Jeff Schaller
    Nov 19, 2015 at 15:50
  • @JeffSchaller no, just that the previous run has completed - so 5 runs one after another regardless
    – sr_1436048
    Nov 19, 2015 at 15:51
  • Then hopefully @TomHunt will write his comment up as an answer :)
    – Jeff Schaller
    Nov 19, 2015 at 15:52

1 Answer 1

1
for i in {1..5}; do php phpfiletoexecute.php; done

This is the stupidest possible version; given more information, you could do things like check if each run succeeded, look at their output if any, and so forth.

3
  • So i just pop that in a php script or run that from the command line? Also the script I'm running doesnt output anything, it reaches a limit and ends. This is a work around. Really appreciate the quick response!
    – sr_1436048
    Nov 19, 2015 at 15:55
  • This is run from the command line, or placed in a shell script.
    – Tom Hunt
    Nov 19, 2015 at 15:56
  • Excellent, worked like a charm thank you @Tom Hunt will accept once it allows me
    – sr_1436048
    Nov 19, 2015 at 15:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .