0
私は、管理ダッシュボードからcronjobコマンドを動的に追加/削除するために、ヒアビートファイルを実行しています。PHPハートビート(cronjobタブ)
私はこのような表にコマンドを保存:
+---------------+-------+------+-------------------+---------------+
| cronjob_id | hour | min | command | output |
+---------------+-------+------+-------------------+---------------+
| 1 | * | * | /mail.php | /mail.log |
| 2 | 00 | 00 | /update.php | /update.log |
+---------------+-------+------+-------------------+---------------+
マイハートビートファイル:
/**
* create a timeset
*/
$hour = date('H');
$minute = date('i');
/**
* select all the commands
*/
$stmt = $db->prepare("SELECT hour,minute,command,output FROM cronjobs");
$stmt->execute();
$result = $stmt->get_result();
while($row = $result->fetch_assoc()){
include_once(ROOT.$row['command']);
error_log("Command: ".$row['command']." executed\n",3,ROOT.$row['output']);
};
$stmt->close();
あなたが見ることができるように、コマンド/mail.phpがごとに実行する必要がありますとコマンド/update.phpは毎日00:00(深夜)にで実行する必要があります。これを私の心拍ファイルにコード化するにはどうすればいいですか?