steviez Posted August 28, 2008 Share Posted August 28, 2008 Hi, I am developing a script that needs a script to run every 24hrs to reset limits but i need it to hapen even if the user forgets or neglets to make the cron command. Is there anything that php can do to simulate cron? Thanks Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted August 28, 2008 Share Posted August 28, 2008 you don't have to run crontab more than once. run it once to set the command and it runs that command every time, once a day, once an hour, whatever. Quote Link to comment Share on other sites More sharing options...
obsidian Posted August 28, 2008 Share Posted August 28, 2008 Is there anything that php can do to simulate cron? No. Remember that PHP is simply a preprocessor scripting language. It has nothing to do with execution or server activities. Your crontab is set up on apache (or scheduled tasks in Windows), and the server action executes the PHP script (or whatever language the script is written in). Quote Link to comment Share on other sites More sharing options...
steviez Posted August 28, 2008 Author Share Posted August 28, 2008 so there is no way to reset limits on a users account every 24hrs without cron? Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted August 28, 2008 Share Posted August 28, 2008 you could store a value in a file or database and check it every single time someone visits the site, to see if it's time to reset user accounts. problems: you probably won't get a visit at exactly 24 hours. if multiple visitors arrive simultaneously (or nearly so), you may have the accounts reset multiple times. why not use crontab? Quote Link to comment Share on other sites More sharing options...
obsidian Posted August 28, 2008 Share Posted August 28, 2008 so there is no way to reset limits on a users account every 24hrs without cron? Again, cron itself will not set the limits of an account, either. Cron simply executes a script in which you have the user's account limits reset. Now, if your site is fairly well trafficked, there may be a way to implicitly check for needed user updates from your visited pages, but your database load would go through the roof with the additional queries... One other thought would be to have each user's information checked when they log in. Have a column in the DB that stores the last time their limits were reset. Then, when they log in, if it has been >= 24 hours, reset their limits and update the timestamp. This would be fairly easy to implement, and it would simulate the resetting you are after. Quote Link to comment Share on other sites More sharing options...
steviez Posted August 28, 2008 Author Share Posted August 28, 2008 thanks for your help, ill look in to this. Quote Link to comment 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.