How to constantly run a php program on a server?

I want to constantly run a php program on the server that will load some things and store them.

I thought to create a script and run this in cron ..

But I wonder if there is any other simple method or light weight that takes up less memory on the server during continuous operation?

I thought of another simple thing

creating a php script with infinite max_execution time and running the code inside the while (true) loop (undefined loop) with some sleep, and then running the program using php ..

What would be the best available way to do this?

+3
source share
6 answers

LooPHP, while(1) ( runloop, GLib, Cocoa, node.js). examples, , ( vs loop driven).

PHP daemon. fooobar.com/questions/516693/... .

, , CRON , ( ), PHP - , .

+2

cron - , .

while(TRUE) sleep() ing , , , cron.

+1

cron ... script, ? , - . script -, , .

0
  • SSH php ?
  • , popen(), php-cli PHP .
  • corntab , - script .
0
source

You can daemonize a PHP script just like you can create a Perl or Python daemon. Starting and stopping the script depends on the operating system. There's a PEAR System_Daemon class that helps you write the PHP daemon.

0
source

IF you are just downloading material from the Internet, would it not be wiser to go with something like wget? On the other hand, if you crawl / clean web pages, I think cronjob would be better

0
source

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


All Articles