PHP长时间运行的脚本停止

时间:2018-10-28 07:04:03

标签: php sql cron

我的视频列表太大了。我每周对其进行检查,以确保视频没有死音,并且一段时间后该脚本在浏览器中停止运行。我运行一台专用服务器,但是我不想增加执行时间。我希望将所有结果显示在一页上,因为我将其设置为滚动到页面底部。 (矩阵样式)

我只是想在正确的方向上获得一些指导。

<?
// Includes
include('db.php');
// Variables
$liveTotal = 0;
$deadTotal = 0;
// Query
$sql = "SELECT * FROM videos WHERE youtube <> '' ORDER BY id DESC";
$deadvideo = mysqli_query ($conn, $sql);
// Flush Buffer
ob_implicit_flush(true);
ob_end_flush();
while ($row = mysqli_fetch_assoc($deadvideo))
    {
        $video_url = @file_get_contents('https://www.youtube.com/oembed?format=json&url=http://www.youtube.com/watch?v=' . $row["youtube"]);
        if(!$video_url)
        {
            // The code below will print all of the dead videos directly to your screen if uploaded in a public directory
            $dead = '<font color="red"><strong>Dead video</strong></font> <a href="https://www.youtube.com/watch?v=' . $row["youtube"] . '">' . $row["title"] . '</a>';
            echo $dead . '<br>';
            $deadTotal++;
        }
        else
        {
            // The code below will print all of the live videos directly to your screen if uploaded in a public directory
            $live = '<font color="darkgreen"><strong>Live video</strong></font> <a href="https://www.youtube.com/watch?v=' . $row["youtube"] . '">' . $row["title"] . '</a>';
            echo $live . '<br>';
            $liveTotal++;
        }
    };
    echo '<br>' . '<strong>Scan Finished</strong>' . '<br>';
    $total = $liveTotal+$deadTotal;
    echo '<br>' . '<strong>Total Videos' . ': ' . $total;
    echo '<br>' . '<strong><font color="darkgreen">Live Videos' . ': ' . $liveTotal . '</font>';
    echo '<br>' . '<strong><font color="red">Dead Videos' . ': ' . $deadTotal . '</font>';
?>

0 个答案:

没有答案
相关问题