0
我正在運行一個hearbeat文件,以從我的管理儀表板動態添加/刪除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(午夜)。我怎樣才能在我的心跳文件中編碼?