CRON runs multiple times after power restore ?

  • Mystery - Real Brain Teaser - I am Totally stumped !


    OMV5 in Pi4 2gb

    nginx in Docker

    local php script running on Nginx


    I have a php script that is run every 20 minutes.

    The php script logs an entry in a .log file ( on the external USB HD connected to the Pi ) , using php code :


    Code
    $extData = fopen($cronLogFile, "a");
    fwrite($extData,date("y-m-d H:i:s")." --- process started" . $LE);  // log entry with current server date and time
    fclose($extData);


    In addition, the OMV > System > Scheduled Jobs has the Cron task, and 'Send Command output via email' is enabled.


    The Scheduled Job command is :

    Code
    docker exec nginx php /config/www/XXXdata/exdgo.php



    Early hours we were having a scheduled power outage - 00h00 to 02h00.


    So we turned off the fiber & network routers, and UPS ( battery dying ) 10 minutes before the power goes off.


    Power does go off, which means no power to the Pi from 00h00 to 02h00. This I am 100% certain of.


    The network router and fiber routers were off until we got up and turned them on at 05h30


    Mystery :

    The log file, created by the php script on the HD, has logs that say the code ran at the 20 minute intervals :



    I also got emails from the Scheduled Jobs ('Send Command output via email') with the same times.

    emails all arrived after the power to the network and fibre routers was restored at 05h30


    So 2 mysteries here :


    Does Cron ( Scheduled Jobs ) run multiple times after power is restored ?

    Power was certainly off until 02h00, but it appears to have run at the 20 minute intervals.


    Why would the 'Scheduled Jobs' NOT run from after 03h00, missing a 3 hour block - would there be some sort of buffer that was full caused by the 10 notifications ( from 00h00 to 03h00 ) that were waiting for internet connection to send out the notifications ?

  • HA !! got it ( I think ) !


    Can anyone confirm my thinking / logic on this ?


    When the power to the Pi restored at around 02h00, the Pi had no internet connection ( fiber routers were off ), and the Pi must have defaulted it's internal time to 00h00


    So the process that is logged as 00h00, actually ran at 02h00 real time.

    The process logged at 03h00 actually ran at 05h00 real time.


    When the routers were powered on ( around 05h30 ), the Pi got internet connection, and updated its own internal time from internet time, and the next cron / scheduled job ran at 06h00

  • DaveOB

    Hat das Label gelöst hinzugefügt.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!