bundyxc Posted August 5, 2009 Share Posted August 5, 2009 My (stupid) host, Yahoo!, doesn't support cron jobs.. but they're mandatory for the simple CMS that I'm making. I was just wondering.. what's the best way to run a script automatically at a certain time every day? I also want to make it customizable through settings.php, but if it's faster to be able to do through a MySQL database I can do that too. I have some code written out, but here's the general idea that I have. settings.php $setResetHours = 13; $setResetMinutes = 4; $setResetSeconds = 20; $resetTime = ($setResetHours * 3600) + ($setResetMinutes * 60) + $setResetSeconds; //Reset time is 01:04:20PM index.php if (x) { //code to be run } I've written out codes before, only to find that I've done it the slowest and most complex way possible, so this time.. I'm going to try to go to you guys first. Thanks for your time. Link to comment https://forums.phpfreaks.com/topic/168879-cron-jobs-without-cron/ Share on other sites More sharing options...
JsusSalv Posted August 5, 2009 Share Posted August 5, 2009 Firstly, get a better host. Secondly, I don't have any scripts for you but check out some of these links for ideas that people have implemented: http://www.weberdev.com/get_example-4498.html http://syn.ac/tech/13/creating-php-cronjobs-without-cron-and-php-cli/ WebBasedCron might help: http://www.webbasedcron.com/ Wordpress plugin: http://www.affordable-internet-marketing.com/2008/01/wordpress-plugin-cron-jobs/ Wish I could help more. Link to comment https://forums.phpfreaks.com/topic/168879-cron-jobs-without-cron/#findComment-891044 Share on other sites More sharing options...
JsusSalv Posted August 5, 2009 Share Posted August 5, 2009 This one is pretty cool as well: phpJobScheduler http://www.phpjobscheduler.co.uk/ Link to comment https://forums.phpfreaks.com/topic/168879-cron-jobs-without-cron/#findComment-891048 Share on other sites More sharing options...
bundyxc Posted August 5, 2009 Author Share Posted August 5, 2009 I only need to run my reset code daily, so how about this... settings.php <?php $setResetHours = 13; //1PM $setResetMinutes = 4; //1:04PM $setResetSeconds = 20; //1:04:20PM $resetTime = ($setResetHours * 3600) + ($setResetMinutes * 60) + $setResetSeconds; //Reset time is 01:04:20PM ?> index.php <?php //Check the last reset time. $resetSelectQuery = "SELECT lastReset FROM settings"; $resetSelectResult = mysql_query($resetSelectQuery,$con) or die (mysql_error() . " : " . $resetSelectQuery); $resetSelectFetch = mysql_fetch_array($resetSelectResult); //Figure out the date of the last reset, as well as the date today. $lastResetDate = date('M-d-Y', $resetSelectFetch['lastReset'); $nowDate = date('M-d-Y', $time) //If today was not the day that the reset last occurred, then run the reset code. if ($nowDate != $lastResetDate) { //reset } ?> Link to comment https://forums.phpfreaks.com/topic/168879-cron-jobs-without-cron/#findComment-891096 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.