简体   繁体   中英

PHP: Cant extend execution time of function

I have an app that scans 100+ domains at the same time my problem is the execution time, I cant extend more than 1.8 min, and displays 404 not found.

This is my code on testing the execution time.

<?php
ini_set('max_execution_time', 300);
// current time
echo date('h:i:s') . "\n";

sleep(120);

// wake up !
echo date('h:i:s') . "\n";

?>

I want to run my functions until it finishes its task.

I hope you can help me.

Thanks.

you can use set_time_limit() for this

https://www.php.net/manual/en/function.set-time-limit.php

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.

If you dont have access to php.ini contact your service provider.

Other option is set bacground script or cronjob on server which takes task from database and maintain its result and create webservice that will montior this process.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM