PHP Running time show

<?php
function getUptime($service) {
    $cacheFile = "cache/{$service}_uptime.cache"; // Cache fájl
    $lastCheckFile = "cache/last_check_time.cache"; // Utolsó ellenőrzés ideje
    $cacheTime = 600; // 10 perc cache idő

    // Ellenőrizzük, hogy létezik-e a cache fájl, és hogy nem járt-e le
    $lastCheckTime = file_exists($lastCheckFile) ? file_get_contents($lastCheckFile) : 0;

    // Ha a cache fájl nem létezik vagy a cache időtartam lejárt
    if (!file_exists($cacheFile) || time() - $lastCheckTime > $cacheTime) {
        // Kérdezd le a szolgáltatás futási idejét
        $output = shell_exec("systemctl show -p ActiveEnterTimestamp $service");
        if ($output) {
            // Kivesszük az időbélyeget
            $timestamp = str_replace('ActiveEnterTimestamp=', '', trim($output));
            $uptime = date('Y-m-d H:i:s', strtotime($timestamp));
            // Cache-eljük az új értéket
            file_put_contents($cacheFile, $uptime);
            file_put_contents($lastCheckFile, time()); // Frissítjük az utolsó ellenőrzés idejét
            return $uptime;
        } else {
            return "A szolgáltatás nem található vagy nem fut.";
        }
    }

    // Használja a cache-ből
    return file_get_contents($cacheFile);
}

// Példák a szolgáltatások futási idejének lekérdezésére
$apacheUptime = getUptime('apache2'); // Apache
$mysqlUptime = getUptime('mysql'); // MySQL
$theloungeUptime = getUptime('thelounge'); // The Lounge
$jellyfinUptime = getUptime('jellyfin'); // Jellyfin
$roundcubeUptime = getUptime('roundcube'); // Roundcube
$discourseUptime = getUptime('discourse'); // Discourse
?>


<div class="card-footer">
    <small class="text-body-secondary">Last updated (Apache): <?php echo $apacheUptime; ?></small>
</div>
<div class="card-footer">
    <small class="text-body-secondary">Last updated (MySQL): <?php echo $mysqlUptime; ?></small>
</div>
<div class="card-footer">
    <small class="text-body-secondary">Last updated (The Lounge): <?php echo $theloungeUptime; ?></small>
</div>
<div class="card-footer">
    <small class="text-body-secondary">Last updated (Jellyfin): <?php echo $jellyfinUptime; ?></small>
</div>
<div class="card-footer">
    <small class="text-body-secondary">Last updated (Roundcube): <?php echo $roundcubeUptime; ?></small>
</div>
<div class="card-footer">
    <small class="text-body-secondary">Last updated (Discourse): <?php echo $discourseUptime; ?></small>
</div>