PHP üzerinde zamanlanmış görevleri çalıştırmak için farklı yaklaşımların bir liste ile gelip çalışıyorum. Benim niyetim PHP zamanlanmış görevleri çalıştırmak için evrensel bir yol sağlamaktır. Şimdiye kadar var:
1) Analyze site traffic. If you receive 770 hits a day (which is one hit per 2 minutes), and you scheduled a task to run at 6:00 AM and a visitor requested a page at 5:59 AM, then run the task because the next visitor will arrive in 6:01 AM on average. Run = exec('/usr/bin/php -f /home/account/cron.php') in this case.
(+) Olarak uzun yolları doğru olarak tüm platformlarda çalışır.
(-) Bazı CPU gücü gerektirir.
(-)) (Exec gerektirir.
(-) Küçük siteler veya büyük bir trafik sivri sitelerde doğru değil.
2) Improved version of the above. When the user requests the page and the task is meant to run, don't use exec() but include() after you have flushed the contents to the user.
(+) Tüm platformlarda çalışır.
(+) Hayır exec () 's.
(-) Bazı CPU gücü gerektirir.
(-) Küçük siteler veya büyük bir trafik sivri sitelerde doğru değil.
3) Running a separate process background so that it is running in a constant loop. Provide an admin interface that let's you "start" and "end" the "service". It will then use fsockopen() to call a .php script that runs infinitely. It uses sleep() to not consume resources and to wake up when the time is right (see: time_sleep_until()). It could search for files and read them to understand when to run what tasks. One could create file "run-everyday-3.00am" that makes the scheduler to run the code inside of it.
(+) Tüm platformlarda çalışır.
(+) Hayır exec () 's.
(Bir dakika bazında uyursa örneğin) (+) oldukça doğru olabilir.
(-) Sabit değil mi - bir sunucu çökmesi tamamen zamanlayıcı durur.
(-) Bazı barındıran bir süreç çalışan 24/7/365 = kaynak domuzu var gibi değil mi?
4) Run exec('crontab') directly on Linux and alike.
(+) Bir kaynak domuzu değildir.
(+) Doğru mudur.
(-) Exec ().
(-) Tüm platformlarda çalışmaz.
5) Asking for cPanel credentials and making a POST to it to create/manage/remove crons.
(+) Doğru mudur
(+) Bir kaynak domuzu değildir.
(-) Güvenlik için kötü
(-) Kullanılabilirlik azaldı = kullanıcı bilgilerini gerektirir
(-) (Windows üzerinde çalışmaz hangi cPanel gerektirir) tüm platformlarda çalışmaz.
(-) CPanel gerektirir.
Diğer fikirler?