| 1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- chdir('/www/wwwroot/emoon.com');
- // 或者使用相对路径
- // chdir(__DIR__ . '/../../..');
- // 然后引入框架
- require 'index.php';
- while (true) {
- try {
- $timestamp = time();
- $timestamp = $timestamp - 5;
- $mapPat['updatetime'] = array('lt',$timestamp);
- $mapPat['strate'] = array('eq',1);
- $updateData["updatetime"] = time();
- $updateData["strate"] = 0;
- $name = db('client') -> where($mapPat) -> update($updateData);
-
- // 记录日志
- file_put_contents(__DIR__ . '/regular_update.log',
- "Updated " . $name . " records at: " . date('Y-m-d H:i:s') . "\n",
- FILE_APPEND);
-
- } catch (Exception $e) {
- // 记录错误
- file_put_contents(__DIR__ . '/regular_update_error.log',
- "Error: " . $e->getMessage() . " at: " . date('Y-m-d H:i:s') . "\n",
- FILE_APPEND);
- }
-
- // 等待5秒
- sleep(5);
- }
- ?>
|