RE: [PHP] Re: Numerical Recipe - Scheduling Question - update...
Hi again... for those who care, feel free to reply with comments... for those who don't.. please ignore!! this is a list of psuedo code/steps/overview of what i'm considering for a kind of scheduling process. the goal is for the user to enter a starttime, as well as specify a periodic function. the resulting output would be the next 'event' time... i've tried to walk through the different scenarios to accommodate the different occurances that i can think of... like i said.. feel free to leave comments.. thanks job scheduler - functions user enters: starttime (now, future) future - day:month:year: hour:min day -dayList, monthList, yearList time-hourList, minList validate date/time interval: type: minutes, hour, day, week, month, last-of-the-month number 1, 2, === when using time, round to 0 secs if user enters only minute: use current hour use current year use current month use current date if user enters only hour: use current min use current year use current month use current date if user enters only min: use current hour use current year use current month use current date if user enters only year: use current min use current hour use current month use current date if user enters only month: use current min use current hour use current year use current date if user enters only date: use current min use current hour use current year use current month if user enters now() (or leaves it blank): app sets min to current min app sets hour to current hour app sets year to current year app sets month to current month app sets date to current date ---++ interval: user selects minutes, user selects 'X' as the numeric interval (if 'X' is blank, app defaults 'X' to 5) app gets the year:month:date hour:min app converts the date/time to secs app creates 'interval' =+.str(X). minute (app computes the next time/secs adding X * 60 for the next 'X' minute) this computes every 'X' minutes using strtotime(interval, secs) -gives every minute at the current 'min', or every 20th minute at the 20min mark, etc.. --note:: should the app roll over minuites.. or should it restart at the hour -- or should it perform both, and let the user decide... user selects hourly, user selects 'X' as the numeric interval (if 'X' is blank, app defaults 'X' to 1) app gets the year:month:date hour:min app converts the date/time to secs app creates 'interval' =+.str(X). hour (app computes the next time/secs adding X * 3600 for the next 'X' hour) this computes every 'X' hour, on the 'min' using strtotime(interval, secs) -gives every hour at the current 'min', or every 2nd Hour at the 10min mark, etc.. user selects daily, user selects 'X' as the numeric interval (if 'X' is blank, app defaults 'X' to 1) app gets the year:month:date hour:min app converts the date/time to secs app creates 'interval' =+.str(X). day (app computes the next time/secs adding X * 60*60*24 for the next 'X' day) this computes every 'X' day, on the 'hour:min' using strtotime(interval, secs) -gives every day at the current 'hour:min', or every 2nd Day at the 2:10pm mark, etc.. user selects weekly, user selects 'X' as the numeric interval (if 'X' is blank, app defaults 'X' to 1) app gets the year:month:date hour:min app converts the date/time to secs app creates 'interval' =+.str(X). week (app computes the next time/secs adding X * 60*60*24 for the next 'X' day) this computes every 'X' week, on the 'day:hour:min' using strtotime(interval, secs) -gives every Mon at the current 'hour:min', or every 2nd Tues at 10:00pm, etc.. user selects monthly, user selects 'X' as the numeric interval (if 'X' is blank, app defaults 'X' to 1) app gets the year:month:date hour:min app converts the date/time to secs app creates 'interval' =+.str(X). month ( redo app computes the next time/secs adding X * 60*60*24 for the next 'X' month) this computes every 'X' month, on the 'date:hour:min' using strtotime(interval, secs) need to include logic to cut limit future month to the 'end date' of the month. don't want to roll over into the next month.. ie, if the date is jan 29, and the next feb only has 28 days.. stop at jan 28... need to incorporate leap year checks, etc... -gives every Month at the current 'date:hour:min', based on the above
RE: [PHP] Re: Numerical Recipe - Scheduling Question
hey shawn... strtotime (or something similar) might just work i'll always know the interval... which can be used to compute the nexttime, which then becomes the next starttime... i'm assuming there's an equally simple way to find the last day of a given month if i choose that as an interval as well.. for my initial needs.. this might work.. until i free up time to actually craft a more generic solution, independent of the underlying language/os.. thanks for next month.. and the start -Original Message- From: Shawn McKenzie [mailto:nos...@mckenzies.net] Sent: Friday, May 29, 2009 2:48 PM To: php-general@lists.php.net Subject: [PHP] Re: Numerical Recipe - Scheduling Question bruce wrote: Hi.. Got a need to be able to allow a user to specify the frequency to run certain apps/processes.. I need to be able to have the user specify a start Time, as well as a periodic frequency (once, hourly, daily, weekly...) as well as allow the user to specify every XX minutes... So i basically need to be able to determine when the future events/occurances are, based on the user input. I've searched the net for alogorithms dealing with scheduling and haven't come up with any php based solutions.. I've also looked at numerical recipes and some other sources (freshmeat/sourceforge/etc..) with no luck.. I have found an approach in another language that I could port to php.. But before I code/recreate this, I figured I'd see if anyone here has pointers or suggestions... Cron doesn't work for me, as it can run a process at a given time.. but it doesn't tell me when the next 'X' occurance would be... Thoughts/Comments.. Thanks This is confusing. When and where do you need to be able to determine when the future events/occurances are? You need to display this after the user schedules the app/process or an admin needs to login and see this at any given time? Regardless it is easy with the PHP time/date functions. Once you've collected and stored the start/stop times and interval, something similar to: $interval = 1 week; $next = $start_time; while ($next = $end_time) { $next = strtotime(+$interval, $next); echo date(DATE_RFC822, $next) .\n; } -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Numerical Recipe - Scheduling Question
hey shawn... on the strtotime function... it appears to simply take intervals of a string type.. is there a way to have it take intervals of the number of secs? or is there another time function that takes the current date/time, and allows you to add an interval in secs? thanks -Original Message- From: Shawn McKenzie [mailto:nos...@mckenzies.net] Sent: Friday, May 29, 2009 2:48 PM To: php-general@lists.php.net Subject: [PHP] Re: Numerical Recipe - Scheduling Question bruce wrote: Hi.. Got a need to be able to allow a user to specify the frequency to run certain apps/processes.. I need to be able to have the user specify a start Time, as well as a periodic frequency (once, hourly, daily, weekly...) as well as allow the user to specify every XX minutes... So i basically need to be able to determine when the future events/occurances are, based on the user input. I've searched the net for alogorithms dealing with scheduling and haven't come up with any php based solutions.. I've also looked at numerical recipes and some other sources (freshmeat/sourceforge/etc..) with no luck.. I have found an approach in another language that I could port to php.. But before I code/recreate this, I figured I'd see if anyone here has pointers or suggestions... Cron doesn't work for me, as it can run a process at a given time.. but it doesn't tell me when the next 'X' occurance would be... Thoughts/Comments.. Thanks This is confusing. When and where do you need to be able to determine when the future events/occurances are? You need to display this after the user schedules the app/process or an admin needs to login and see this at any given time? Regardless it is easy with the PHP time/date functions. Once you've collected and stored the start/stop times and interval, something similar to: $interval = 1 week; $next = $start_time; while ($next = $end_time) { $next = strtotime(+$interval, $next); echo date(DATE_RFC822, $next) .\n; } -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Numerical Recipe - Scheduling Question
2009/5/29 bruce bedoug...@earthlink.net: hey shawn... on the strtotime function... it appears to simply take intervals of a string type.. is there a way to have it take intervals of the number of secs? or is there another time function that takes the current date/time, and allows you to add an interval in secs? $timestamp = time() + $num_secs; -Stuart -- http://stut.net/ -Original Message- From: Shawn McKenzie [mailto:nos...@mckenzies.net] Sent: Friday, May 29, 2009 2:48 PM To: php-general@lists.php.net Subject: [PHP] Re: Numerical Recipe - Scheduling Question bruce wrote: Hi.. Got a need to be able to allow a user to specify the frequency to run certain apps/processes.. I need to be able to have the user specify a start Time, as well as a periodic frequency (once, hourly, daily, weekly...) as well as allow the user to specify every XX minutes... So i basically need to be able to determine when the future events/occurances are, based on the user input. I've searched the net for alogorithms dealing with scheduling and haven't come up with any php based solutions.. I've also looked at numerical recipes and some other sources (freshmeat/sourceforge/etc..) with no luck.. I have found an approach in another language that I could port to php.. But before I code/recreate this, I figured I'd see if anyone here has pointers or suggestions... Cron doesn't work for me, as it can run a process at a given time.. but it doesn't tell me when the next 'X' occurance would be... Thoughts/Comments.. Thanks This is confusing. When and where do you need to be able to determine when the future events/occurances are? You need to display this after the user schedules the app/process or an admin needs to login and see this at any given time? Regardless it is easy with the PHP time/date functions. Once you've collected and stored the start/stop times and interval, something similar to: $interval = 1 week; $next = $start_time; while ($next = $end_time) { $next = strtotime(+$interval, $next); echo date(DATE_RFC822, $next) .\n; } -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Numerical Recipe - Scheduling Question
bruce wrote: hey shawn... strtotime (or something similar) might just work i'll always know the interval... which can be used to compute the nexttime, which then becomes the next starttime... i'm assuming there's an equally simple way to find the last day of a given month if i choose that as an interval as well.. If you search, there are 100s of ways to do these types of things. Check the date/time functions. There are many and many ways to use theme. Here is one: date('t', strtotime($year-$month-01)); for my initial needs.. this might work.. until i free up time to actually craft a more generic solution, independent of the underlying language/os.. thanks for next month.. and the start -Original Message- From: Shawn McKenzie [mailto:nos...@mckenzies.net] Sent: Friday, May 29, 2009 2:48 PM To: php-general@lists.php.net Subject: [PHP] Re: Numerical Recipe - Scheduling Question bruce wrote: Hi.. Got a need to be able to allow a user to specify the frequency to run certain apps/processes.. I need to be able to have the user specify a start Time, as well as a periodic frequency (once, hourly, daily, weekly...) as well as allow the user to specify every XX minutes... So i basically need to be able to determine when the future events/occurances are, based on the user input. I've searched the net for alogorithms dealing with scheduling and haven't come up with any php based solutions.. I've also looked at numerical recipes and some other sources (freshmeat/sourceforge/etc..) with no luck.. I have found an approach in another language that I could port to php.. But before I code/recreate this, I figured I'd see if anyone here has pointers or suggestions... Cron doesn't work for me, as it can run a process at a given time.. but it doesn't tell me when the next 'X' occurance would be... Thoughts/Comments.. Thanks This is confusing. When and where do you need to be able to determine when the future events/occurances are? You need to display this after the user schedules the app/process or an admin needs to login and see this at any given time? Regardless it is easy with the PHP time/date functions. Once you've collected and stored the start/stop times and interval, something similar to: $interval = 1 week; $next = $start_time; while ($next = $end_time) { $next = strtotime(+$interval, $next); echo date(DATE_RFC822, $next) .\n; } -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php