Set maximum execution time in MYSQL / PHP

前端 未结 5 1530
名媛妹妹
名媛妹妹 2020-12-03 12:18

I have an XML document that has around 48,000 children (~50MB). I run an INSERT MYSQL query that makes new entries for each one of these children. The problem is that it tak

相关标签:
5条回答
  • 2020-12-03 12:24

    You can make it by setting set_time_limit in you php code (set to 0 for no limit)

    set_time_limit(0);
    

    Or modifying the value of max_execution_time directly in your php.ini

    ;;;;;;;;;;;;;;;;;;;
    ; Resource Limits ;
    ;;;;;;;;;;;;;;;;;;;
    
    ; Maximum execution time of each script, in seconds
    ; http://php.net/max-execution-time
    ; Note: This directive is hardcoded to 0 for the CLI SAPI
    max_execution_time = 120  
    

    Or changing it with ini_set()

    ini_set('max_execution_time', 120); //120 seconds
    

    but note that for this 3rd option :

    max_execution_time

    You can not change this setting with ini_set() when running in safe mode. The only workaround is to turn off safe mode or by changing the time limit in the php.ini.

    Source www.php.net

    0 讨论(0)
  • 2020-12-03 12:33

    You can use the ini_set at the start of your application.

    ini_set('max_execution_time', *number of seconds here*); //300 seconds = 5 minutes
    
    0 讨论(0)
  • 2020-12-03 12:39

    maximum execution time for Apache Web Server is 300 seconds (5 min), so if your script is very long you have to options

    1. your script can be executed on most 5 minutes open php.ini file and chanage max_execution_time = (seconds) for example to max_execution_time = 300

    2.if you scripts need mor than 5 minutes you should first change Httpd.conf file (Apache config file)

    TimeOut (number of seconds you want)
    

    and also in php.ini max_execution_time = (number of seconds you want)

    0 讨论(0)
  • 2020-12-03 12:45

    You can Set maximum execution time in MYSQL / PHP. it's so easy.

    To set maximum execution time in single PHP file, place this code just after your first opening php tag.

    ini_set(‘max_execution_time’, 0)
    

    To set maximum execution time in php.ini file. You can set as per your require.

    max_execution_time=360 //360 seconds = 6 minutes
    

    To set maximum execution time in htaccess file.

    php_value max_execution_time 0
    

    You can also read step by step here.

    0 讨论(0)
  • 2020-12-03 12:46

    Put this at the top of your script:

    ini_set('max_execution_time', 300);
    

    That'll make it 5 minutes.

    0 讨论(0)
提交回复
热议问题