How to create a continuous while loop, if it is already running, do not run it again, I assume that if the script is running, it will update the last time cron in the database, and the script checks if the current time is not - 40 seconds less than the last time cron. An example of what I have, but this is an overflow (running process again and again) Thanks!
<?php
ignore_user_abort(1);
set_time_limit(0);
function processing()
{
setting::write('cron_last_time', $time);
}
$time = current_timestamp();
$time_before = $time - 20;
$settings = setting::read('module_cron_email');
$time_last = $settings['setting_value'];
if ($time_before < $time_last)
{
do{
processing();
sleep(7);
continue;
}
while(true);
}else{
echo "already running";
die();
}
?>
source
share