verycleanteeth Posted April 25, 2007 Share Posted April 25, 2007 I'm creating a racing simulation in PHP that I want to run in semi-real time. I'll explain. A bunch of people sign up for a race. They sit and stare at a page that updates about every 10 seconds with the new positions of all the racers and some details about the race. Now the rub. How on Earth do I set up a script that will run every 10 seconds and do what I need it to do? I've read that cron should only be used for things spaced a bit further apart. My service provider specifically requests we don't have any scripts that run within 5 minutes of themselves. Link to comment https://forums.phpfreaks.com/topic/48565-solved-racing-simulation/ Share on other sites More sharing options...
benjaminbeazy Posted April 25, 2007 Share Posted April 25, 2007 you can use a meta refresh tag, or a a javascript refresh, or php header refresh or header location. you can do a google search to get full instructions for each and to decide which is best for you. there are other ways. google is an amazing resource for code Link to comment https://forums.phpfreaks.com/topic/48565-solved-racing-simulation/#findComment-237856 Share on other sites More sharing options...
verycleanteeth Posted April 25, 2007 Author Share Posted April 25, 2007 The problem with those solutions is I need this script to run even if no one is actively watching it. If people want they can watch the race "live", or they can wait until it's over and read a transcript of what transpired. If I rely on a javascript refresh or a header refresh, and no one is watching the race happen, nothing will fire. I hope that makes sense. Link to comment https://forums.phpfreaks.com/topic/48565-solved-racing-simulation/#findComment-237858 Share on other sites More sharing options...
benjaminbeazy Posted April 25, 2007 Share Posted April 25, 2007 correct, if no one accesses the page, it wont refresh... you could run a cronjob every 5 or 10 minutes on the script and have the script process all the action that happens in between then, every 10 seconds or whatever with sleep() Link to comment https://forums.phpfreaks.com/topic/48565-solved-racing-simulation/#findComment-237865 Share on other sites More sharing options...
verycleanteeth Posted April 25, 2007 Author Share Posted April 25, 2007 Thank you. The sleep function is precisely the sort of thing I was looking for Link to comment https://forums.phpfreaks.com/topic/48565-solved-racing-simulation/#findComment-237911 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.