If you don’t have a cron in your serveer, you can use this script to run a daily cron job.
Prepare a writeable file with a date inside and name it as ‘crondate.php’. The file should contain only date in one line.
2012-09-22
Run this function in a file on your website. It will check whether today’s date and date in file are different.
If yes, then it will call any function you want to run daily
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | function cron_daily_check() { //read file to get last date $filename = 'crondate.php'; $handle = fopen($filename, 'r'); $filedate = fgets($handle); //if date different, run a function and update file date if (date('Y-m-d') != $filedate) { /***** call any function or script to execute here ****/ //write new date $fh = fopen($filename, 'w') or die("Failed to open file."); $stringData = date('Y-m-d'); fwrite($fh, $stringData); fclose($fh); } } |