process - Calling PHP multiple times within a CRON job (self-calling until an exit condition is satisfied) -


I plan to synchronize 2 folders to 2DIFIFERS servers that are every hour . The script to be determined, will check whether the previous example is already running or not, and if not, then continue with processing.

So, the first step is to sync these folders. Daily (or more often), the second server will have 1-2 thousand new files, which must be first transferred to the server and processed.

Processing will be controlled by PHP, it opens every file, reads each line and adds it to a database.

What I want to do is use the same cron which sends folders to call php scripts to parse files. But since I do not know how long it will take to take action on many files, I want to apply a limit on the number of files handled by PHP on every request.

For any PHP scripts (number of files / each request), if it has not been added, it can easily reach one timeout.

The question is: Is there any way I can keep looping and call this PHP script until this process is finished? Ideally when both wget (folder sync) and PHP will expire, the lock will be removed so that a new instance of the cron can be run.

Any suggestion is welcome, thank you

Code> headers () and can get the parameter to control the execution flow. For example:

parse.php? Action = 1

In the script:

  switch ($ _GET ["action"]) {Case 1: // Action 1 is the title here (" place: ... "); Go out(); break; Case 2: // Action 2 Here header ("Location: ..."); break; }  Go out();  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -