简体   繁体   中英

Automatically run a php script

I am connecting to an eCommerce website's API, to get product reviews from them, what I want to do is to set the product ID which I want it's review using a loop iterator from 1 to 10, for example:

loop from i = 1 until 10
product_id=i
// here I want to tell my php script to resubmit itself with the new product_id

I found that cron would submit it to me, but then I won't be able to loop on the product_id, I will have to synchronize between the cron and the iterator in the php script which is not efficient solution at all. does anyone know how to help me

You can rewrite your php script to use $argv http://php.net/manual/en/reserved.variables.argv.php

then you can pass it like

#!/bin/bash
for i in {1..5}
do
   php script.php $i
done 

save it as .sh file and add it to CRON

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM