[wd_asp elements=’search’ ratio=’100%’ id=1]

Cron jobs – Depending on day – write file

20th August 2014

Php - Dates & Time

php codehaven

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.

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

?>