Reputation: 1221
To monitor the max_execution_time
of a particular script, I use
ini_set('max_execution_time', 600); //600 seconds = 10 minutes
at the top of my script. However, when I build a logging of the same file it returns me the following:
25-09-2017 23:08:01|STARTED
25-09-2017 23:09:01|ALREADY RUNNING
25-09-2017 23:10:01|ALREADY RUNNING
...................|ALREADY RUNNING
26-09-2017 01:09:01|ALREADY RUNNING
26-09-2017 01:10:01|ALREADY RUNNING
26-09-2017 01:11:01|STARTED
26-09-2017 01:12:01|ALREADY RUNNING
26-09-2017 01:13:01|ALREADY RUNNING
...................|ALREADY RUNNING
26-09-2017 03:10:01|ALREADY RUNNING
26-09-2017 03:11:01|ALREADY RUNNING
26-09-2017 03:12:01|STARTED
26-09-2017 03:13:01|ALREADY RUNNING
26-09-2017 03:14:02|ALREADY RUNNING
...................|ALREADY RUNNING
26-09-2017 05:09:01|ALREADY RUNNING
26-09-2017 05:10:02|ALREADY RUNNING
26-09-2017 05:11:01|STARTED
26-09-2017 05:12:01|ALREADY RUNNING
26-09-2017 05:13:02|ALREADY RUNNING
26-09-2017 05:14:01|ALREADY RUNNING
...................|ALREADY RUNNING
26-09-2017 07:14:01|ALREADY RUNNING
26-09-2017 07:15:01|ALREADY RUNNING
26-09-2017 07:16:01|STARTED
The ...................|ALREADY RUNNING
represents multiple messages repeating every minute in between.
What am I doing wrong, since the interval is not 10 minutes by far?
EDIT:
The while loop I have:
while (true) {
//DO PROCESSING WHEN FILES ARE PRESENT
Sleep(1);
}
Upvotes: 0
Views: 435
Reputation: 668
Just check execution time manually.
$max_exec_time = 600;
$start_time = time();
while (true) {
do_something();
sleep(1);
if (time() - $start_time > $max_exec_time) {
exit;
}
}
Upvotes: 1