This is not a real cron, as this is used in Linux systems, scheduled tasks are what windows uses.
Not maybe the correct way, but it shows you how to control lots of times, then set something happening, useful if you have to have lots of individual tasks in a script, quicker to control.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
<?php $firstday = date('Y-m-d', mktime(+1, 0, 0, date("m"), 1, date("Y"))); $sevendays = date('Y-m-d', strtotime('+6 days', strtotime($firstday))); $fourteendays = date('Y-m-d', strtotime('+13 days', strtotime($firstday))); $twentyonedays = date('Y-m-d', strtotime('+20 days', strtotime($firstday))); $twentyeightdays = date('Y-m-d', strtotime('+27 days', strtotime($firstday))); $thisdaynum=date("j"); //*********************************************************************************************************** if ($thisdaynum<8) { //echo "8,9,10,11,12,13,14"; $filetodelete = "emails/28-whatever.txt"; //reset last months file unlink($filetodelete); echo "No predicted forecast available"; $filename = 'emails/7orless.txt'; if (file_exists($filename)) { } else { include('predicted.php'); // file to run $handle = fopen('emails/7orless.txt','a'); // file name to write fwrite ($handle); fclose($handle); echo " - Updated"; } } else //*********************************************************************************************************** if ($thisdaynum>7 && $thisdaynum <15) { //echo "8,9,10,11,12,13,14"; $filetodelete = "emails/7orless.txt"; //reset last months file unlink($filetodelete); echo "Using forecast as of 8th"; $filename = 'emails/7-15.txt'; if (file_exists($filename)) { } else { include('predicted.php'); // file to run $handle = fopen('emails/7-15.txt','a'); // file name to write fwrite ($handle); fclose($handle); echo " - Updated"; } } else //*********************************************************************************************************** if ($thisdaynum>14 && $thisdaynum <22) { //echo "15,16,17,18,19,20,21"; $filetodelete = "emails/7-15.txt"; //reset last months file unlink($filetodelete); echo "Using forecast as of 15th"; $filename = 'emails/15-22.txt'; if (file_exists($filename)) { } else { include('predicted.php'); // file to run $handle = fopen('emails/15-22.txt','a'); // file name to write fwrite ($handle); fclose($handle); echo " - Updated"; } }//end of if function else //*********************************************************************************************************** if ($thisdaynum>21 && $thisdaynum <29) { //echo "22,23,24,25,26,27,28"; $filetodelete = "emails/15-22.txt"; //reset last months file unlink($filetodelete); echo "Using forecast as of 22nd"; $filename = 'emails/22-29.txt'; if (file_exists($filename)) { } else { include('predicted.php'); // file to run $handle = fopen('emails/22-29.txt','a'); // file name to write fwrite ($handle); fclose($handle); echo " - Updated"; } }//end of if function else //*********************************************************************************************************** if ($thisdaynum>28) { //echo "28,29,30 etc"; $filetodelete = "emails/22-29.txt"; //reset last months file unlink($filetodelete); echo "Using forecast as of 29th"; $filename = 'emails/28-whatever.txt'; if (file_exists($filename)) { } else { include('predicted.php'); // file to run $handle = fopen('emails/28-whatever.txt','a'); // file name to write fwrite ($handle); fclose($handle); echo " - Updated"; } } //end of if function ?> |