PHP and scheduled tasks

I am trying to find a list of different approaches for running scheduled tasks in PHP. My intention is to provide a universal way to run scheduled tasks in PHP. So far, I:

1) Analysis of site traffic. If you receive 770 hits per day (this is one hit in 2 minutes), and you scheduled a task to start at 6:00 in the morning, and the visitor requested the page at 5:59 in the morning, then run the task because the next visitor will arrive on average at 6:01 a.m. Run = exec ('/ usr / bin / php -f / home / account / cron.php') in this case.

(+) Works on all platforms as long as the paths are correct.

(-) Some processor power is required.

(-) Requires exec ().

(-) Inaccurate on small sites or on sites with huge traffic traffic.

2) Improved version above. When a user requests a page and the task is intended to run, do not use exec (), but include () after you reset the contents of the user.

(+) Works on all platforms.

(+) No exec ().

(-) Some processor power is required.

(-) Inaccurate on small sites or on sites with huge traffic traffic.

3) , . , "" "" "". fsockopen() .php script, . sleep(), , (.: time_sleep_until()). , , . "run-daily-3.00am", .

(+) .

(+) exec().

(+) (, ).

(-) - .

(-) , 24/7/365 = hog?

4) exec ('crontab') Linux .

(+) .

(+) .

(-) exec().

(-) .

5) cPanel POST // .

(+)

(+) .

(-)

(-) =

(-) ( cPanel, Windows).

(-) cPanel.

?

+3
5

, , , .

- cron , curl .

, , .

+4

Windows VisualCron http-, , , . V-C , .

, Zack cron + curl cron + wget

http://www.visualcron.com http://www.visualcron.com/img/screenshots/v5/mainwindow/mainwindow_bluetheme.png

+2

- Windows ? CRON UNIX. (1) PHP script, (2), CRON UNIX Windows script PHP CLI.

script, HTTP . UNIX Windows. wget -, .

+1

/ . , , ..

, "?"

0

IMHO, ...

User code <=> [User interface]<-> Your library <->[Technology interface] <=> Technology execution module (method)

, ... , , .

BTW, " " PHP- /-.

If I were you, I would look for an existing library / module, and I would not create a background process if the underlying system cannot handle the scheduled tasks (unix and windows process them).

0
source

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


All Articles