c0rnf3d Posted October 31, 2008 Share Posted October 31, 2008 i have a year or two of experience with php but have found myself needing to write a fairly complex script and im not sure if what i need to do can be done with php. i will give a bit of background first. the goal here is to send out emails to a user based off 'recommended items' based off their search history from my site. so i have 20k members and over a 5 million page records. because of the complexity of finding a list of 'recommended items' i do not want this to execute all at one time, i would like to space things out. ( i dont wanna kill the server) lets say i want to limit the execution of this script to 2k people per hour (maby low or high, i have no clue, just throwing a number out), firstly how would i limit this... the next thing is say i want to log in 3 hours later and check the status of whats going on... how would i do that? i dont want to hit the page again and start the initial execution of the script again... Thanks in advance Link to comment https://forums.phpfreaks.com/topic/130920-solved-help-with-php-scripts-that-take-awhile-to-execute/ Share on other sites More sharing options...
Maq Posted October 31, 2008 Share Posted October 31, 2008 For executing only 2k people at a time use LIMIT. Write a recursive function that passes in the start/finish positions and increment them by 2k. If you can keep track of how long 2k records takes to process you can do something like this in pseudo: sleep() = (1 hour - time already executed). For your second problem, write to a log file and you can watch the -tail of it in actual run time (you have to do some research cause I forget the command for this). Hope this helps. Link to comment https://forums.phpfreaks.com/topic/130920-solved-help-with-php-scripts-that-take-awhile-to-execute/#findComment-679571 Share on other sites More sharing options...
c0rnf3d Posted October 31, 2008 Author Share Posted October 31, 2008 that does help. didnt realize there was a sleep command in php - i suck - so, lets say i wanted to execute this script from an admin panel, and then pause + resume. that possible? Link to comment https://forums.phpfreaks.com/topic/130920-solved-help-with-php-scripts-that-take-awhile-to-execute/#findComment-679577 Share on other sites More sharing options...
Maq Posted October 31, 2008 Share Posted October 31, 2008 that does help. didnt realize there was a sleep command in php - i suck - so, lets say i wanted to execute this script from an admin panel, and then pause + resume. that possible? Please read this. sleep — Delay execution. Link to comment https://forums.phpfreaks.com/topic/130920-solved-help-with-php-scripts-that-take-awhile-to-execute/#findComment-679601 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.