0

I have set the max_input_time 600000 and max_execution_time 600000, upload_max_filesize 1GB, memory_limit 512M But still my Script stops after 5 minutes of execution.

Basically what I want is, When I Run a PHP Script to Import or Export bigger Files. It exports just half file and Stops. Or If I try to upload 400 or 450 MB file It stops.

I tried import .sql file using PHP Script. It stopped after 5 Minutes and there were only 18 Tables with records were able to be imported in those 5 minutes, other 50 Tables were still pending.

I want to Run the Script at least for about 20 to 30 minutes, So My Script can complete the Process.

Please let me know what I should do, Should I Make some more changes in the php.ini file or something else. Whatever you will advise

  • 1
    I believe this is an [x y problem](https://xyproblem.info/) If your script really needs 20 - 30 minutes to run, there's almost certainly a better way to do whatever it is doing. Perhaps you'd be better served if your php script were to queue all the exports it needs to perform in some way (via database records or rabbitmq etc) and then have another system that works that queue to process all the exports. – Wesley Smith Nov 27 '20 at 05:14
  • 1
    I think you should enable logs and check for critical errors. This way, you will know for sure what was the real reason of script break. Scripts could be breaked not only by memory/time allocation. Sometimes you could have invalid data for the script. Or in your situation, there maybe database connection break errors – Urmat Zhenaliev Nov 27 '20 at 05:52
  • @UrmatZhenaliev Yes. I have done so. The Data is Good. No issue with Data At all.if i import the same file manually, It works perfect. But if i do with the Script it stops – Muhammad Baber Zaman Nov 27 '20 at 06:26
  • Even if data is Ok there should be information about error. It will show us the direction. Could you provide us with it? – Urmat Zhenaliev Nov 27 '20 at 06:30

1 Answers1

0

Browser Does not support 20-30 minutes to waiting for a response from the server. You can run PHP scirpt file using the command line.

pmali
  • 67
  • 1
  • 6
  • how i can use via command line. I am not aware of it. Please – Muhammad Baber Zaman Nov 27 '20 at 05:17
  • Suppose we do not need the script to run for 20 to 30 minutes. But at least we need to run the script to process the full function. Suppose i have 48 Mib file sql . When i start importing it. It imports a part from it. not import full. after importing some part of it. it stops. Even if we use a smaller file having less records. it uploads full. So we cannot say that the script is not good. Just the timing is the issue only – Muhammad Baber Zaman Nov 27 '20 at 05:19
  • and More over. This script will work behind the browser. how, I just uploaded a files. Started its process. I Closed the browser and starting watching in Database. Records are coming for about some minutes. Then records stops. – Muhammad Baber Zaman Nov 27 '20 at 05:23
  • you can import .sql file using mysql command https://stackoverflow.com/questions/17666249/how-do-i-import-an-sql-file-using-the-command-line-in-mysql – pmali Nov 27 '20 at 05:24
  • Yes. But there are many files. And The Admin will just select and Import the database. So, He dont know how to do with commands. So better is the PHP Importing. Just the issue is how to make a script keep running in background until the process is completed. – Muhammad Baber Zaman Nov 27 '20 at 05:47