seany123 Posted February 9, 2009 Share Posted February 9, 2009 I dont know if this is in the correct sections but ill ask here anyway. on my website i have a cron page in place to everytime the page is loaded and its in X amount of time the page update my database. the problem is, if i dont have anyone online to load the page then the cron wont happen and it obviously doesnt back date... (so it only runs once) is there any programs or websites i could use which would stay constantly on that page? refreshing every couple seconds... or does anyone have any ideas of how i could get this to do it when i have no people online. Quote Link to comment https://forums.phpfreaks.com/topic/144422-crons/ Share on other sites More sharing options...
corbin Posted February 9, 2009 Share Posted February 9, 2009 Uh.... You mention cron like you're using it, but at the same time, it seems like your not using it? Are you or are you not using a crontab? If not, you should be. Quote Link to comment https://forums.phpfreaks.com/topic/144422-crons/#findComment-757873 Share on other sites More sharing options...
seany123 Posted February 11, 2009 Author Share Posted February 11, 2009 well my host dont support crons, but yeah i am useing a self made "cron tab". and its working good, but im needing a way to execute that page every minute. Quote Link to comment https://forums.phpfreaks.com/topic/144422-crons/#findComment-759604 Share on other sites More sharing options...
trq Posted February 11, 2009 Share Posted February 11, 2009 but im needing a way to execute that page every minute. Then you need to find a host that supports cron jobs. All good hosts do. Quote Link to comment https://forums.phpfreaks.com/topic/144422-crons/#findComment-759614 Share on other sites More sharing options...
redarrow Posted February 11, 2009 Share Posted February 11, 2009 use this service then http://www.onlinecronjobs.com/ Quote Link to comment https://forums.phpfreaks.com/topic/144422-crons/#findComment-759619 Share on other sites More sharing options...
seany123 Posted February 13, 2009 Author Share Posted February 13, 2009 use this service then http://www.onlinecronjobs.com/ sadly that service wont work, it only allows for crons every 15 minutes. i want my crons to be updated every minute. Quote Link to comment https://forums.phpfreaks.com/topic/144422-crons/#findComment-761173 Share on other sites More sharing options...
blueman378 Posted February 13, 2009 Share Posted February 13, 2009 use this service then http://www.onlinecronjobs.com/ sadly that service wont work, it only allows for crons every 15 minutes. i want my crons to be updated every minute. updating your crons every minute is a REALLY bad idea, it will create way to much stress on your server... Quote Link to comment https://forums.phpfreaks.com/topic/144422-crons/#findComment-761190 Share on other sites More sharing options...
Mark Baker Posted February 13, 2009 Share Posted February 13, 2009 i want my crons to be updated every minute.Surely the only justification for crons every minute is if you're getting enough activity on your pages to warrant it. What does this script do that it requires to run every minute? Quote Link to comment https://forums.phpfreaks.com/topic/144422-crons/#findComment-761212 Share on other sites More sharing options...
seany123 Posted March 2, 2009 Author Share Posted March 2, 2009 im making a browser based game.... values such as hospital time and prison time would need to reduced every minute... it would only be updateing say 1 or 2 values per player. Quote Link to comment https://forums.phpfreaks.com/topic/144422-crons/#findComment-774495 Share on other sites More sharing options...
killah Posted March 2, 2009 Share Posted March 2, 2009 What browser based game are you making? And i have a browser based game. I have also the page which updates the user. This script does not need to perform every minute. How ever what it does is. When some one clicks after like 10 minute's. It all add's up so when he click's it does not remove 1 it remove's all 10. Try this script: <?php $result = mysql_query("SELECT * FROM `updates` WHERE `name` = '1min'"); $result = mysql_fetch_assoc($result); $hla = time() - $result['last']; if($hla > (60)) { $n = floor($hla / 60); $hos = mysql_query("SELECT userid FROM `users` WHERE `hospital` <> 0"); $hos = mysql_num_rows($hos); $jail = mysql_query("SELECT userid FROM `users` WHERE `jail` <> 0"); $jail = mysql_num_rows($jail); $hospital = (1 * $n); $jail = (1 * $n); $query_hos = sprintf("UPDATE users SET hospital = hospital - %u WHERE hospital <> 0", $hospital); $query_jail = sprintf("UPDATE users SET jail = jail - %u WHERE jail <> 0", $jail); mysql_query($query_hos); mysql_query($query_jail); $time = time(); mysql_query("UPDATE `updates` SET `last` = ".$time." WHERE `name` = '1min'"); $floor = $time - (floor($time / 60) * 60); if($floor > 0) { $newUpdate = time() - $floor; mysql_query("UPDATE `updates` SET `last` = ".$newUpdate." WHERE `name` = '1min'"); } } ?> Your table structure: Table => updates => name last Then insert into updates: Name => 1min Last => unix_timestamp(); Quote Link to comment https://forums.phpfreaks.com/topic/144422-crons/#findComment-774498 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.