dreamBox Posted January 2, 2011 Share Posted January 2, 2011 Hi all, I am working on a project where I need to monitor accounts and suspend features associated with them if their deposited balance runs out. To do this I'm thinking it might be best to have a script running with an infinite loop that constantly refreshes but I'm not sure what kind of strain this might put on the server. The pseudocode would look something like this: while (1) { For each row in database { If balance <= 0 { mysql query - account_status = suspended } } } Please note (obviously) this is psuedocode and not actual code. I'm just concerned about how I would stop this script timing out, and what kind of impact it would have on server performance? Is there any better way to do this? Happy to discuss, dB Quote Link to comment Share on other sites More sharing options...
trq Posted January 2, 2011 Share Posted January 2, 2011 An infinite loop is definitely not a good option. this would be much better done by having the script scheduled to execute every minute (or whatever). This can be done via either Cron on Linux or Scedual Task on Windows. Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted January 2, 2011 Share Posted January 2, 2011 Why infinite loop? may be you will look into cronjobs(cron).[if i get you correctly] http://en.wikipedia.org/wiki/Cron Quote Link to comment Share on other sites More sharing options...
litebearer Posted January 2, 2011 Share Posted January 2, 2011 why repeatedly check rows that may have had no activity since the last check, when checking the balance whenever a row is updated may be easier and take less server time? ie A) query to update balance (this query should already contain some unique field value so as to only update a particular row) B) query to check value of new balance - if balance <=0 - suspend 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.