Mam taki kod w cron:
  1. <?php
  2.  
  3. $date = new DateTime(date('Y-m-d H:i:s'), new DateTimeZone('America/New_York'));
  4. $date->setTimezone(new DateTimeZone('Europe/Warsaw'));
  5. $data = $date->format('H:i d.m.Y');
  6.  
  7. $p = fopen('czas.txt', w);
  8. fwrite($p, '');
  9. fclose($p);
  10. $dane = $data;
  11. $file = 'czas.txt';
  12. $fp = fopen($file, "a");
  13. flock($fp, 2);
  14. fwrite($fp, $dane);
  15. flock($fp, 3);
  16. fclose($fp);
  17.  
  18. $c = curl_init();
  19. curl_setopt($c, CURLOPT_URL, "http://racegame.pl/");
  20. curl_setopt($c, CURLOPT_NOBODY, 1);
  21. curl_exec($c);
  22.  
  23. if(curl_getinfo($c, CURLINFO_HTTP_CODE) == 200) {
  24.  
  25. $p = fopen('racegame_pl.txt', w);
  26. fwrite($p, '');
  27. fclose($p);
  28. $dane = "1";
  29. $file = 'racegame_pl.txt';
  30. $fp = fopen($file, "a");
  31. flock($fp, 2);
  32. fwrite($fp, $dane);
  33. flock($fp, 3);
  34. fclose($fp);
  35.  
  36. } else {
  37.  
  38. $p = fopen('racegame_pl.txt', w);
  39. fwrite($p, '');
  40. fclose($p);
  41. $dane = "0";
  42. $file = 'racegame_pl.txt';
  43. $fp = fopen($file, "a");
  44. flock($fp, 2);
  45. fwrite($fp, $dane);
  46. flock($fp, 3);
  47. fclose($fp);
  48.  
  49. }
  50.  
  51. curl_setopt($c, CURLOPT_URL, "http://racegame.webd.pl/");
  52. curl_setopt($c, CURLOPT_NOBODY, 1);
  53. curl_exec($c);
  54.  
  55. if(curl_getinfo($c, CURLINFO_HTTP_CODE) == 200) {
  56.  
  57. $p = fopen('racegame_webd_pl.txt', w);
  58. fwrite($p, '');
  59. fclose($p);
  60. $dane = "1";
  61. $file = 'racegame_webd_pl.txt';
  62. $fp = fopen($file, "a");
  63. flock($fp, 2);
  64. fwrite($fp, $dane);
  65. flock($fp, 3);
  66. fclose($fp);
  67.  
  68. } else {
  69.  
  70. $p = fopen('racegame_webd_pl.txt', w);
  71. fwrite($p, '');
  72. fclose($p);
  73. $dane = "0";
  74. $file = 'racegame_webd_pl.txt';
  75. $fp = fopen($file, "a");
  76. flock($fp, 2);
  77. fwrite($fp, $dane);
  78. flock($fp, 3);
  79. fclose($fp);
  80.  
  81. }
  82.  
  83. curl_setopt($c, CURLOPT_URL, "http://racegame.pl/forum/");
  84. curl_setopt($c, CURLOPT_NOBODY, 1);
  85. curl_exec($c);
  86.  
  87. if(curl_getinfo($c, CURLINFO_HTTP_CODE) == 200) {
  88.  
  89. $p = fopen('racegame_pl_forum.txt', w);
  90. fwrite($p, '');
  91. fclose($p);
  92. $dane = "1";
  93. $file = 'racegame_pl_forum.txt';
  94. $fp = fopen($file, "a");
  95. flock($fp, 2);
  96. fwrite($fp, $dane);
  97. flock($fp, 3);
  98. fclose($fp);
  99.  
  100. } else {
  101.  
  102. $p = fopen('racegame_pl_forum.txt', w);
  103. fwrite($p, '');
  104. fclose($p);
  105. $dane = "0";
  106. $file = 'racegame_pl_forum.txt';
  107. $fp = fopen($file, "a");
  108. flock($fp, 2);
  109. fwrite($fp, $dane);
  110. flock($fp, 3);
  111. fclose($fp);
  112.  
  113. }
  114.  
  115. /*curl_setopt($c, CURLOPT_URL, "http://servhost.pl/");
  116. curl_setopt($c, CURLOPT_NOBODY, 1);
  117. curl_exec($c);
  118.  
  119. if(curl_getinfo($c, CURLINFO_HTTP_CODE) == 200) {
  120.  
  121. $p = fopen('servhost_pl.txt', w);
  122. fwrite($p, '');
  123. fclose($p);
  124. $dane = "1";
  125. $file = 'servhost_pl.txt';
  126. $fp = fopen($file, "a");
  127. flock($fp, 2);
  128. fwrite($fp, $dane);
  129. flock($fp, 3);
  130. fclose($fp);
  131.  
  132. } else {
  133.  
  134. $p = fopen('servhost_pl.txt', w);
  135. fwrite($p, '');
  136. fclose($p);
  137. $dane = "0";
  138. $file = 'servhost_pl.txt';
  139. $fp = fopen($file, "a");
  140. flock($fp, 2);
  141. fwrite($fp, $dane);
  142. flock($fp, 3);
  143. fclose($fp);
  144.  
  145. }*/
  146.  
  147. curl_setopt($c, CURLOPT_URL, "http://transgame.pl/");
  148. curl_setopt($c, CURLOPT_NOBODY, 1);
  149. curl_exec($c);
  150.  
  151. if(curl_getinfo($c, CURLINFO_HTTP_CODE) == 200) {
  152.  
  153. $p = fopen('transgame_pl.txt', w);
  154. fwrite($p, '');
  155. fclose($p);
  156. $dane = "1";
  157. $file = 'transgame_pl.txt';
  158. $fp = fopen($file, "a");
  159. flock($fp, 2);
  160. fwrite($fp, $dane);
  161. flock($fp, 3);
  162. fclose($fp);
  163.  
  164. } else {
  165.  
  166. $p = fopen('transgame_pl.txt', w);
  167. fwrite($p, '');
  168. fclose($p);
  169. $dane = "0";
  170. $file = 'transgame_pl.txt';
  171. $fp = fopen($file, "a");
  172. flock($fp, 2);
  173. fwrite($fp, $dane);
  174. flock($fp, 3);
  175. fclose($fp);
  176.  
  177. }
  178.  
  179. ?>


Nie rozumiem dlaczego jak cron wykonuje skrypt nie zapisuje czasu... A jak ręcznie go odpale to go zapisze.
  1. $date = new DateTime(date('Y-m-d H:i:s'), new DateTimeZone('America/New_York'));
  2. $date->setTimezone(new DateTimeZone('Europe/Warsaw'));
  3. $data = $date->format('H:i d.m.Y');
  4.  
  5. $p = fopen('czas.txt', w);
  6. fwrite($p, '');
  7. fclose($p);
  8. $dane = $data;
  9. $file = 'czas.txt';
  10. $fp = fopen($file, "a");
  11. flock($fp, 2);
  12. fwrite($fp, $dane);
  13. flock($fp, 3);
  14. fclose($fp);


http://thedulimen.dejm.pl/skrypty_cron/strona/czas.txt

Tutaj powinien zmieniać się czas co 5 minut jednak się nie zmienia, gdy uruchomimy ręcznie ten skrypt:

http://thedulimen.dejm.pl/skrypty_cron/strona/strona.php

Czas się zmieni, jednak gdy idzie przez crona nie chce...