CRONを使用してphpファイルを実行することに関する多くの投稿があることを知っています。しかし、共有ホスティングの世界では、ユーザーにとってセットアップが簡単なので、私はそれをいじる必要はありません。
ソケットに関係する別の解決策をオンラインで見つけました。みんなにこれを受け入れてもらいたかっただけで、これが良いアイデアか悪いアイデアか教えてください。それはうまくいくように聞こえます。
考え?
//Open socket connection to cron.php
$socketcon = fsockopen($_SERVER['HTTP_HOST'],80,$errorno,$errorstr,10);
if($socketcon) {
$socketdata = "GET /cron.php HTTP 1.1\r\nHost: ".$_SERVER['HTTP_HOST']."\r\nConnection: Close\r\n\r\n";
fwrite($socketcon,$socketdata);
//Normally you would get all the data back with fgets and wait until $socketcon reaches feof.
//In this case, we just do this:
fclose($socketcon);
} else {
//something went wrong. Put your error handler here.
}
cron.php:
//This script does all the work.
sleep(200);
//To prove that this works we will create an empty file here, after the sleep is done.
//Make sure that the webserver can write in the directory you're testing this file in.
$handle = fopen('test.txt','w');
fclose($handle);
ブログ投稿からスクリプトを見つけました: http://syn.ac/tech/13/creating-php-cronjobs-without-cron-and-php-cli/