-2

I want to execute php script at exact microtime, or after it if it hasn't been executed, 1minute is too much range for me. Is there such possibility?

azurinko
  • 261
  • 2
  • 11

1 Answers1

0

Assuming you already know how to use cron, set your script to start on the minute before the precise microtime you want stuff to happen. Pass the microtime value you want as an argument to the script and put this before the rest of your code.

<?php
// get the start time from the argument passed to the script
$startTime = $argv[1];

// wait until it's time
while (microtime(true) < $startTime);

// do stuff
Don't Panic
  • 41,125
  • 10
  • 61
  • 80