M
M
Max Payne2015-02-12 17:34:28
PHP
Max Payne, 2015-02-12 17:34:28

Why is cron not reading the file?

Here is the code I have. Reads the last 5 topics in the community and sends me the last message from them if it hasn't already been sent. I, like a decent Alyoshka, so as not to fool around, I just write to a file and that's it. I will give only part of the code, the rest has nothing to do with the question :)

<?php
...
for($i = 1; $i <= 5; $i++) {
$offset = $topics['response']['topics'][$i]['comments'] - 1;
$is1 = "https://api.vk.com/method/board.getComments?access_token=".$token."&group_id=GID&topic_id=".$topics['response']['topics'][$i]['tid']."&offset=".$offset."&count=1";
$topics1 = json_decode(file_get_contents($is1),true);
echo $topics1['response']['comments'][1]['date']."\r\n";
$t = $topics['response']['topics'][$i]['tid'];
echo file_get_contents("vk/".$t.".txt");
if($topics1['response']['comments'][1]['date'] != file_get_contents("vk/".$topics['response']['topics'][$i]['tid'].".txt")) {
file_put_contents("vk/".$topics['response']['topics'][$i]['tid'].".txt",$topics1['response']['comments'][1]['date']);
...
?>

The bottom line is that when I try to run the code from the browser, it regularly checks the file and does not send me a message if the unix timestamp written to the file is not equal to the label I received from vk api.
But when the cron is triggered, the fun begins - it just sends me a message every time without seeing the file to which I write with FPC.
Here is a quote from the cron logs:
1422817926
Warning: file_get_contents(vk/31014373.txt): failed to open stream: No such file or directory in /home/u850898830/public_html/board.php on line 15

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Fateev, 2015-02-12
@YardalGedal

The point, most likely, is that '/home/u850898830/'
add the working folder for cron to the beginning of the script:
chdir('/home/u850898830/public_html/');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question