i started to code a toplist script.in this script i will only store two data for each site: today hit and yesterday hit.every midnight 00:00 i will take today hit and write it on yesterday hit and make todays hit 0.is there any other way doing this job without cron job?
First of all you should say - is it a script for frontend or for backend purposes. I mean is it just for showing hits for other users or really store information. At the first case you need something like this: keep the last changing date of the action in some file(or db) and every time users request script check if you need to make action (check will basic on the last date). At the second case you will need only cron or similar tool.
A cron job would be by far the easiest way of doing it - but it's not the only way. Each time your page is loaded, you could make a check to see if the archiving needs doing and then, if it does, do it. The actual update is not likely to take very long. However, you would need to lock the table so that if another user requested the page before the update completed, you didn't end up with both processes trying to do the update. But cron jobs are *very* easy to set up (assuming you have access to them of course).
thank you for your answers @ecentricNick: i thought checking now but there is a missing point there.i couldn't check if that script doesn't run.i mean when time is 00:37 and if the script doesn't run until that time it will still display the yesterday hit.i mean to show the today hit that script should be run once or a user will enter that site using cron job is the easiest way i think