I have a line of code that needs to be executed from an user-defined start time to an user defined end time.
The problem is that a normal loop from start to end doesn't work because PHP gives me an error of "Execution Time Limit Exceeded".
How do I get this done without using CRON jobs? (I need to run my server on a Windows PC)

- 5,837
- 8
- 34
- 61

- 1,252
- 4
- 18
- 38
-
You would need something sitting there checking the time and firing code if a specific time is hit. Use C#? – Chris Nov 25 '12 at 14:44
-
1What about this for PHP.. http://www.phpclasses.org/package/4140-PHP-Database-driven-PHP-job-scheduler-like-cron.html – Chris Nov 25 '12 at 14:46
-
1Maybe your problem isn't really the problem. Maybe if you tell us more detail about why you are trying to do this, and what you are trying to do, someone can give you a better solution. – Buttle Butkus Nov 26 '12 at 09:24
3 Answers
Windows or not it's not excuse. Any platform features tools to let you do scheduled tasks. So does Windows. Here is tutorial about setting up Scheduled Tasks on Windows to achieve same results like you can with cron.
EDIT
I need to do this on a web-browser. It needs to be platform independent.
You can't really. The only trick to do something close to cron w/o cron is to check dates on each request users made to your scripts and if the time is right, fire do some job. But if noone visit your site then you start nothing.
Other option is to setup cron which would do the request to your page (i.e. using wget, lynx, HEAD etc). But it still needs the "driving force" like cron or equivalent

- 72,056
- 11
- 123
- 141
-
I need to do this on a web-browser. It needs to be platform independent. – Kanishka Ganguly Nov 25 '12 at 12:57
-
The scheduled tasks that @WebnetMobile.com speaks of will be run at server level, so the browser has nothing to do with it. – Chris Nov 26 '12 at 09:33
-
@KanishkaGanguly you can't make something from nothing. See edited answer – Marcin Orlowski Nov 26 '12 at 09:55
-
Yes. I got your point. Makes sense. But I think I have reached a solution. Javascript works just fine and does the job. – Kanishka Ganguly Nov 27 '12 at 06:21
Try to change your "Execution Time Limit" in your PHP.ini

- 383
- 1
- 4
- 15
-
That is not a very elegant solution. The time entered by the user can go up to hours. – Kanishka Ganguly Nov 25 '12 at 13:07
I solved the problem. Using javascript and the setTimeout() function, I sent a GET request to the necessary php script and the line of code was executed after that delay.

- 1,252
- 4
- 18
- 38