Script runs twice

Links for php scripts

Moderators: gesf, Michalio

Post Reply
juljan555

The below script on a server with PHP-FPM and PHP 8 runs twice. Second time exactly after 1 minute. Stack with Nginx in front and Apache in the back. Already set timeout exec and input to 1 hour.
*******************************
<?php

/*
* The purpose of this script is to see if cron jobs running more than 1 minute
* recall themselves

You can add a message by using &note=ThisUsingCronMessage

call like: https://wdleadscalls.org/cronjobs/testm ... NoteForYou

*/

//Did they add a note
if (isset($_GET['note'])){
$note = $_GET['note'];
}else{
$note = "";
}



$Now = date('Y-m-d H:i:s');
echo "<h2> Starting This At $Now (Note:$note)</h2>";
$fp = fopen('LOGtestmultical2.txt', 'a');//opens file in append mode.
$Now = date('Y-m-d H:i:s');
$Msg = "\n Program Launched At: $Now";
fwrite($fp, $Msg);

fclose($fp);

$StartNow = $Now;

//Sleep for 4 minutes
sleep(241);


$fp = fopen('LOGtestmultical2.txt', 'a');//opens file in append mode.
$Now = date('Y-m-d H:i:s');
$Msg = "\n Program Finished At: $Now Started At:($StartNow) (Note:$note)";
fwrite($fp, $Msg);

fclose($fp);


$Now = date('Y-m-d H:i:s');
echo "<h2> FINISHING This At $Now Started At:($StartNow) (Note:$note)</h2>";

Any idea why? Where should I look?
User avatar
Michalio
Moderator
Moderator
Posts: 360
Joined: Sun Jul 18, 2021 1:33 pm
Location: Poland

"Stack with Nginx in front and Apache in the back"
what does it mean?

It looks like the issue is somewhere else
Free coding lessons: https://php-forum.com/phpforum/viewtopic.php?t=29852
Post Reply