SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict jasongr's Avatar
    Join Date
    Jul 2004
    Location
    usa
    Posts
    371
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ensuring that PHP is given unlimited execution time

    Hi people

    I have a PHP scripts that needs to perform a lot of work.
    I need to make sure that the script will never timeout and will never stop its execution in the middle.
    I tried something like:
    PHP Code:
    ini_set('max_execution_time'36000);    // 10 hours
    set_time_limit(0);
    $original_ignore_user_abort ignore_user_abort(false);
    // a lot of work here....
    ignore_user_abort($original_ignore_user_abort); 
    However, sometimes it doesn't work, and the script stops after a while.
    Am I doing something wrong? Can anyone suggest a better approach?

    regards

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Do the work in parts, ie. do a chunk then rest for a bit then do another chunk etc.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  3. #3
    SitePoint Addict jasongr's Avatar
    Join Date
    Jul 2004
    Location
    usa
    Posts
    371
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no, I need to do all the work in a single request

  4. #4
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Ok...clearly you can't, you can set whatever "max_execution_time" you want but the OS cuts your process off when it excceds its time share and it has to wait for all the other processes to finish before it gets to go again. So find a way to break the work down.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  5. #5
    SitePoint Enthusiast
    Join Date
    Sep 2005
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    are you on a shared host? if you are you may have to use a .htaccess file to manipulate php ini values.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •