I am developing software that is similar to fantasy football applications.
I have user accounts with information pertaining to each of them stored in a relational database in mysql. I have a php script that I want to run after all of the games are finished to update every member's stats at once (there could be thousands of users).
After researching it seems like the best solution would be to set up a cron tab using Unix.
I am wondering if this would be the correct solution?
If I set up this crontab to run every Tuesday would it run the PHP script which would update the user information?
Is a cron tab easy to set up with Unix for a simple website?
Setting up crons is really simple. If you have shell access, simply type #crontab -e and it will bring you to the cron settings. Check out this link: Crontab - Quick Reference.
What you simply do is create a PHP script and link it through the cron tab. If you are running a server with cPanel, there is a built-in cron manager too, if you prefer to do it in a GUI.
You did not give enough information for me to say anything conclusive about this, but you want to balance the script out so that it either 1) runs frequently enough so that it has to update small enough changes--for example, if 100 records are changed every hour, running the script every day will mean it has to update 2400 records, whereas if you run it once a week, it has to update 16800 recods, which probably is so severe that it will raise your server load. And/ or 2) break up your updates in chunks. For example if records only change once a week, but at that time 16800 records change, then you might want to either have your scripts run for 1000 updates and put it to sleep for a while, run some more, sleep, etc (this is a bad habit, but it is the simplest I suppose), or you run your cron script frequently, every time it does 1000 updates, and at the end of it, it will leave a trace (for example, the last ID number) of the last change it has updated into the database so that the script can pick up on that the next time it runs.
If you want me to draft up some more elaborate examples the illustrate the two different approaches, please let me know.