Long php processes

I need to run a very long php script (four and a half, five hours).

The script sometimes runs successfully, but sometimes it is killed inexplicably (maybe something has to do with shared hosting?).

I think the solution, possibly for running the script, is smaller pieces.

To do this, I wrote a script file that saves its status and position in an XML file and executes one piece of script before moving the position.

I'm having trouble connecting the last bit of the script, which should terminate the current process and re-execute the script.

or maybe I'm completely barking on the wrong tree!

I read what I can find in SO and elsewhere, but I'm still not wiser :(

Please, help!!!

Dan

+3
5

, script, , , cronjob.

, , script, , , . , , script (getmypid()) .

PID:

  • PID script (to/tmp/script_pid)
  • Trigger cronjob . PID , .

php exec() ( ) , linux "ps".

:

  • .
  • Trigger cronjob . timestamp X, .

, X .

+2

PHP . , ? SSH script php /path/to/script.php.

, , Apache/PHP , . , .

+1

, . PHP script , , (- , ). AJAX, ;)

+1

cron , script .

+1

I agree with Josh and suppose you program it in some other way, like a desktop application, if possible. PHP was sure it wasn’t built for something like this, which requires the script to run for 4-5 hours. It can be sure that max_execution_time or script will consume the processor on shared hosting, but switching to a desktop application or SSH is the training that I offer you.

0
source

Source: https://habr.com/ru/post/1741576/


All Articles