Reputation: 73
I use cron jobs
at 8:00. and i want my file run 3 times by different value
Example:
test.php?id=1
test.php?id=2
test.php?id=3
How i can run top file in cron jobs
at 8:00 simultaneously ?
Upvotes: 1
Views: 1212
Reputation: 174
<?php
$myarray = array();
$myarray[] = 1;
$myarray[] = 2;
$myarray[] = 3;
foreach($myarray as $myarr){
$d = $myarr;
page_code($d); //this function call page code in every loop and pass different value
}
function page_code($id){
//Insert page code inside this function
}
?>
create array ($myarray) with all possible values. And call page code from function, inside the loop. no need to run different crone. All ids run with single cron. Tis code work for me. Thanks
Upvotes: 0
Reputation: 2466
Use id field as an array. For ex-
$ids =array('1','2','3');
Than use loop, and call the function. For ex-
foreach($ids as $id){
$this->CronFunction($id);
}
This way your code will execute with three different value at same time. No need create separate file for all three value.
Upvotes: 0
Reputation: 752
You need add params to php cli script and read $argv to get this params http://php.net/manual/en/reserved.variables.argv.php for example
0 8 * * * php script.php 1
0 8 * * * php script.php 2
0 8 * * * php script.php 3
Upvotes: 1