-
Notifications
You must be signed in to change notification settings - Fork 605
Bypass PHP Long Running Tasks Limits
By default PHP has time limit that prevents to run long foreground tasks. This can be an issue using weevely when we want to run long-running tasks like find
. Read here how to tweak the PHP settings and live happily.
-
Example PHP configuration:
max_execution_time = 30
-
Used modules:
system_info
,shell_php
The time limit is set in the max_execution_time
in the php.ini
file. Check the value on your current weevely session using :system_info
.
www-data@target:/var/www/html $ :system_info -info max_execution_time
30
The default configuration kills any PHP task longer then 30 seconds. This can be bypassed using set_time_limit(0);
, @ignore_user_abort(1);
, and ini_set(max_execution_time,0);
which are usually combined to unset the PHP time limit.
We can permanently set the prefix_string
option of the shell_php
weevely module in order to prepend these calls in the entire session and disable the time limit.
www-data@target:/var/www/html $ :set shell_php.prefix_string @error_reporting(0);set_time_limit(0);@ignore_user_abort(1);ini_set(max_execution_time,0);
shell_php.prefix_string = @error_reporting(0);set_time_limit(0);@ignore_user_abort(1);ini_set(max_execution_time,0);
The time limit is now disabled for the entire session. Run :system_info
and a long example task to check whether max_execution_time
has been effectively disabled.
www-data@target:/var/www/html $ :system_info -info max_execution_time
0
www-data@target:/var/www/html $ sleep 50 && echo "This hasn't been killed after 30s!"
This hasn't been killed after 30s!
www-data@target:/var/www/html $
Changing max_execution_time
at runtime has no effect when PHP is running in safe mode.