Stop a script execution

Discussion in 'PHP' started by ranacseruet, May 22, 2010.

  1. #1
    I have made a script that will run for a long time(set script execution limit to infinity). This is executing via ajax. now even if i close the browser tab its still executing(i am knowing it via a status log). So, if I want to stop this execution upon closing the browser tab, what should i do?

    Regards
     
    ranacseruet, May 22, 2010 IP
  2. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #2
    kindly post the script that calls back
     
    bartolay13, May 23, 2010 IP
  3. mfscripts

    mfscripts Banned

    Messages:
    319
    Likes Received:
    4
    Best Answers:
    8
    Trophy Points:
    90
    Digital Goods:
    3
    #3
    Restart Apache (assuming you have root access)
     
    mfscripts, May 24, 2010 IP
  4. ranacseruet

    ranacseruet Peon

    Messages:
    302
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    How to do that please? can you please give an example?
     
    ranacseruet, May 24, 2010 IP
  5. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #5
    post your script
     
    bartolay13, May 24, 2010 IP
  6. ranacseruet

    ranacseruet Peon

    Messages:
    302
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Simply consider this:

    
    set_time_limit(0);
    for($i=0; $i<50000;$i++){
     // A lot of insert/update to database here...
    } 
    
    Code (markup):
     
    ranacseruet, May 24, 2010 IP
  7. shubhamjain

    shubhamjain Active Member

    Messages:
    215
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    63
    #7
    See phpinfo(); and make sure that ignore_user_abort is turned off.
     
    shubhamjain, May 25, 2010 IP
  8. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #8
    If you have cpanel or another control panel, look in your process list (Under Apache Status), find the PID # for the process that won't stop, and run "kill PID" in a ssh prompt.
     
    jestep, May 25, 2010 IP