I have only done the things you're looking to do with cron. Cron will run FAITHFULLY on the minute if you use it, and you might consider submitting the user request over to a cron process where they won't be able to change anything by refreshing.
PHP is server-based coding, so you're going to have a difficult time on the client (browser) end getting things to output, and if it's output you're looking for consider using Javascript to call either an iframe to get content refreshed, or AJAX.
Now, supposing you choose to either use a cron process or just call a page once. If you call the page once you might try this - and this is shorthand so you have some work to do 🙂
while(true){
//you must put in a condition to break when all is satisfied or error condition or you'll create an endless loop
if( "this second is closest to a modulus of your target of 180 s. increments on the clock" ){
//call the procedure you wish to call
}else{
//come back again
sleep(1);
continue;
}
}
note that will run the process at the first even 3:00 mark, so you might delayed up to 2:59 theoretically for the first call to execute. Alternately, if the process should run immediately, that becomes the marker time (suppose it's 18:32 or 6:32.1054 PM and we then want to run at 6:35.1054, 6:38.1054 etc..), then something like this should work:
function three_minutes_past(){
global $initialRunTime, $j;
if( floor( (time() - $initialRunTime) / 180 ) > $j ) return true;
}
$i=0;
$j=0;
while(true){
//you must put in a condition to break when all is satisfied or error condition or you'll create an endless loop
$i++;
if($i==1){
$initialRunTime=time();
}
if($i==1 || three_minutes_past()){
//call the procedure
$j++;
}
sleep(1);
}