Advertisement
djyarik

Запуск скрипта каждый час/день/размер файла (аналог cron)

Aug 4th, 2016
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.57 KB | None | 0 0
  1. // for Autodor.SQLite.Wmsn https://goo.gl/QiUFBc
  2. #=============fast server http://vk.cc/7BSP3h ===========
  3. // Срабатыват при при заходе человека или робота на сайт))
  4. <?
  5.  
  6. //Запуск каждый день Файл сам создается!
  7.  
  8. if (!file_exists('data.txt')) {file_put_contents("data.txt","");}
  9. $fdata=file_get_contents("data.txt");
  10. $data = date("ymd"); if ($data!=$fdata)  
  11.     { file_put_contents("data.txt", date("ymd"));  
  12.  
  13.  
  14. //Ваш скрипт тут
  15.  }
  16. ?>
  17. ------------------------------------------------------
  18. <?
  19. //Запуск каждые 1 часов. Файл сам создается!
  20.  
  21. $last_cron_time = file_get_contents("data1.txt");
  22. $period = time() - 60 * 60 * 1; //Где 1 это 1 час. (Ставить больше 6-24 часов не рекомендуется, так как время обнуляется в 00,00)
  23. if ($last_cron_time < $period)
  24. { file_put_contents("data1.txt", time());
  25.  
  26.  
  27. //Ваш скрипт тут
  28.    }
  29. ?>
  30. -------------------------------------------------------
  31. <?
  32. //Запуск скрипта при изменении файла
  33. if (!file_exists('file.txt')) {file_put_contents("file.txt","");}
  34. $ddd = 'db/' .$host. '.db';  //Путь к файлу, в данном случае база
  35. $crontime2=filesize($ddd);
  36. $crontime1=file_get_contents("file.txt");
  37.  if ($crontime1!=$crontime2 and $crontime2 < 40 * 1024 *1024 )  //и файл меньше 40Мб
  38.     { file_put_contents("file.txt", filesize($ddd));  
  39. //Ваш скрипт тут
  40. }
  41.  
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement