There is a program for delayed execution. I want to execute a program every minute. what is the PHP idea? how can I write it?
For example, for (I = 0; I <1000; I ++ ){
Program Logic
I want to delay one minute before executing the task and then perform the next loop. how can I write this? it seems that the php page has been timed out for a long time?
}
Reply to discussion (solution)
For ($ I = 0; I I <1000; $ I ++ ){
Echo $ I;
Sleep (60); // runs every 60 seconds
}
Use sleep ();
We recommend that you use system scheduled tasks.
Will SLEEP be canceled due to system timeout?
Will SLEEP be canceled due to system timeout?
Will SLEEP be canceled due to system timeout?
Set_time_limit (0) does not time out and quit.
The page is always open,
Set_time_limit (0); does not time out the page
Sleep (60); this allows the program to sleep for 60 seconds before execution.
But it is not recommended to do this. it mainly depends on your logic. We recommend that you use crontab.
Enter
Crontab-e ***** php handle. php> handle. log: wq