Situation: I have a online game (similar to yahtzee) website that keeps stats for all users. Every time the web page is loaded, stats are loaded via SQL from the database (think high scores, average score) and displayed on the screen.
For now, this works fine. But what happens if I get more complicated quieries, or many many games. The queries would take a long time. Could I have the quieries executed nightly? Then when the webpage is loaded for the users, they could just reference the nightly update (either file, or condensed rules table)?
Question: Is there a way I can have all of my 'all games' queries be executed automatically every night? If there are 10000+ games, the average score really wouldn't change much from game to game. If it was just updated every night, that would be good enough.
I know I could write an event listener to check the system date, and if it is a new day, (midnight) perform the quieries. But that would only work IF the website is open. How can I have this process work 100% of the time? Do I have to have something else set up on the server in order to get something like this to work?
- Oh, and if you want to check out my website and see what I am talking about... check it out
you can set a cronjob to run scripts on a server
I have 2 servers suppliers, 1 has a cronjob wizard in the cpanel, the other I just email with a time, frequency and url I want hit and they set it for me
I see now how to set up a cron job. I haven't done that before, but it looks like a easy way to get the job done.
Would the cron job be able to open a .swf file that would then execute my queries? Or how should I set it up? I could have my cron job open a webpage which has a flex file which would execute my queries?
Thanks for the help- sorry I don't know a lot about the limitations of cron jobs.
Would you care to share your syntax for cron jobs commands to give me a start?