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 Link to comment https://forums.phpfreaks.com/topic/121734-cron-help/ 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. Link to comment https://forums.phpfreaks.com/topic/121734-cron-help/#findComment-627996 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). Link to comment https://forums.phpfreaks.com/topic/121734-cron-help/#findComment-627999 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? Link to comment https://forums.phpfreaks.com/topic/121734-cron-help/#findComment-628003 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? Link to comment https://forums.phpfreaks.com/topic/121734-cron-help/#findComment-628007 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. Link to comment https://forums.phpfreaks.com/topic/121734-cron-help/#findComment-628009 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. Link to comment https://forums.phpfreaks.com/topic/121734-cron-help/#findComment-628020 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.