I have a question about PHP and CRON-Jobs. I've made a php script which some time have to load very very long, because there are many commands. Because of this I made several smaller scripts, so the commands are fewer. I made then a "master-script" which executes some POST-Request over Javascript. But as you know Cron doenst execute Javascript. And the whole script needs to execute as one big script because of the dependence between the scripts.
Is it somehow possible to set the time before a loading-timeout higher on the server or is this just from browser to browser?
Or are there any other ideas how I could solve this?
Thank you
For PHP cronjobs, you can set the timeout and memory limit like this:
// make sure we have enough time and memory.
ini_set('memory_limit', -1);
ini_set('max_execution_time', 0);
set_time_limit(0);
I think you mean something like this, please post some of your code next time.
If you already have split up your script into multiple smaller ones, and you make sure that they can run within the max_execution_time
allowed on your server, than you'll have to create a page that handles all javascript calls. All this page does is creating a session that 'remembers' which 'smaller scripts' should run, in which order and what current script is running/has run. Your browser just requests through AJAX to process 'the current step'.
So in pseudo code it could look like this:
Start session
Load all 'steps' of subscripts
Increment step number (save to session!)
Do processing (subscript 1/2/3/etc) ...
Output status info to browser and let javascript 'poll' this page for next step/status info.
thank you all for the answers.
I just found another method:
I made a switch with an $_GET variable. So now every "Sub-Script" is now in one case of the switch and at the end it changes the $_GET to the next step.