Skip to content

Instantly share code, notes, and snippets.

@jakeydevs
Last active April 16, 2016 17:53
Show Gist options
  • Save jakeydevs/860446423c0a1ecf245765252cb91b5d to your computer and use it in GitHub Desktop.
Save jakeydevs/860446423c0a1ecf245765252cb91b5d to your computer and use it in GitHub Desktop.
Run every X seconds
<?PHP
//-- Run at least every 5 seconds
$diff = 5;
//-- Get my time
$time_check = 0;
//-- Always run
while (1) {
//-- Get time now
$time = microtime();
if ((microtime() - $time_check) > $diff) {
//-- WORKING CODE
//-- Reset the time check
$time_check = microtime();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment