skip to Main Content

I have a php script that need to be processed for one to 5 hours (sending newsletters to our customers). I tried both set_time_limit(2000); and ini_set('max_execution_time', 360000); but neither works. They work perfectly on the XAMPP local server, but they do not work on our dedicated server (Unix & Apache). I also changed the Apache timeout to 300 (which was 50), yet after 30 seconds of script running, it returns this:

Internal Server Error Page (Error 500)

I have no idea if there is any other place for timeout and/or why the server does not honor the ini_set() or set_time_limit() functions. We are using Unix CentOS 6 and Plesk 11.9 as server. I also changed the default php.ini max_execution_time, and it works…

I read many articles and forums, yet I don’t know why this happens. I appreciate your help.

4

Answers


  1. Chosen as BEST ANSWER

    I appreciate your answers and comments. I setup the cron job, and it works perfect. I also have tried the chunk-chunk (150 emails per chunk) approach, and that one works too.


  2. a better way would be using ini_set() or set_time_limit() at the top of the script which sends newsletters to the customers…you should not try to main config files…and also, as someone suggested above, cron jobs are good fit for such situations..

    Login or Signup to reply.
  3. // add, in your php file header or config

    ini_set('max_execution_time','256'); //max_execution_time','0' <- unlimited time
    ini_set('memory_limit','512M');
    

    Good work!

    Login or Signup to reply.
  4. If you using Vps:
    Edit your php.ini file:

    max_execution_time = 256
    memory_limit = 512M
    

    Then, run command line to restart apache

    service httpd restart
    

    Or header file

    ini_set('max_execution_time','256');
    ini_set('memory_limit','512M');
    

    Good luck!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search