在php中如何在精确的微时间执行脚本

在php中如何在精确的微时间执行脚本,php,cron,Php,Cron,我想在精确的微时间执行php脚本,或者在它之后,如果它还没有执行,1分钟对我来说太长了。有这样的可能性吗?假设您已经知道如何使用cron,请将脚本设置为在您希望事情发生的精确微时间前一分钟开始。将所需的microtime值作为参数传递给脚本,并将其放在代码的其余部分之前 <?php // get the start time from the argument passed to the script $startTime = $argv[1]; // wait until it's t

我想在精确的微时间执行php脚本,或者在它之后,如果它还没有执行,1分钟对我来说太长了。有这样的可能性吗?

假设您已经知道如何使用cron,请将脚本设置为在您希望事情发生的精确微时间前一分钟开始。将所需的microtime值作为参数传递给脚本,并将其放在代码的其余部分之前

<?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

你通常只需要一分钟就可以了,为什么你需要这么精确呢?我不正常。我也可以把它压到一秒钟。你不能精确到一秒钟,我想你也不需要它。如果你有一个chron作业,它会在那一分钟发生,而不是在那一分钟内的任何时候。你可以执行cron,并等待一定的秒数。。。