I have a php file that will run on Monday and Tuesday only any time between 9 to 10 AM.
The php file is controlled via Cron jobs and I have a batch file that will run every 2 minutes and send mail ( using task schedular I'm running the bat file every 2 minutes)
The problem is:
The if condition gets satisfied between 9 to 10 AM and send the mail repeatedly. I want the myMondayTuesdayMailList() function to run only once a day by setting some flag or by someway to handle this
In other words, there are plenty of functions running inside send_mail.php and the function myMondayTuesdayMailList() should be executed only once on Monday and Tuesday only even if the page is refreshed/reloaded via cron again and again ( I know I need to set some flag or variable but I'm blank now. Help me out).
How can I achieve this
send_mail.php
<?php
$get_day = date('D');
$get_time = date('H');
if(($get_day == 'Mon' and $get_time >=9 and $get_time <= 10) || ($get_day == 'Tue' and $get_time >=9 and $get_time <= 10)){
{
myMondayTuesdayMailList();
}
function myMondayTuesdayMailList(){
....... my query and php stuffs to send mail..........
}
function testfunction1(){
}
function testfunction2(){
}
?>
cron.bat
start "mailinglist" "C:\xampp\php\php.exe" -f C:\xampp\htdocs\test\send_mail.php