Update.php 973 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. chdir('/www/wwwroot/emoon.com');
  3. // 或者使用相对路径
  4. // chdir(__DIR__ . '/../../..');
  5. // 然后引入框架
  6. require 'index.php';
  7. while (true) {
  8. try {
  9. $timestamp = time();
  10. $timestamp = $timestamp - 5;
  11. $mapPat['updatetime'] = array('lt',$timestamp);
  12. $mapPat['strate'] = array('eq',1);
  13. $updateData["updatetime"] = time();
  14. $updateData["strate"] = 0;
  15. $name = db('client') -> where($mapPat) -> update($updateData);
  16. // 记录日志
  17. file_put_contents(__DIR__ . '/regular_update.log',
  18. "Updated " . $name . " records at: " . date('Y-m-d H:i:s') . "\n",
  19. FILE_APPEND);
  20. } catch (Exception $e) {
  21. // 记录错误
  22. file_put_contents(__DIR__ . '/regular_update_error.log',
  23. "Error: " . $e->getMessage() . " at: " . date('Y-m-d H:i:s') . "\n",
  24. FILE_APPEND);
  25. }
  26. // 等待5秒
  27. sleep(5);
  28. }
  29. ?>