D
D
Daniil Chashkov2018-01-08 20:52:01
PHP
Daniil Chashkov, 2018-01-08 20:52:01

Why doesn't php script work with cron?

Tell me, what could be wrong here?
If I write another code, say, to write the word "hello" to a file, then the scheduler will execute the task, but if I write such code, it does not.
Could this be due to the use of Read Bean Php?

<?php
include './system/db/connect.php';

if($user->hp < $user->max_hp){
  $hp = $user->max_hp/100*10;
  $user->hp += $hp;
  R::store($user);
}
?>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry Entelis, 2018-01-08
@DmitriyEntelis

Write in the cron to save the output to a file, most likely there will be an error text.
In telepath mode, I can assume that the problem is with the inclusion path.
In any case, this piece of code can be guessed ad infinitum, we need logs.

S
Saboteur, 2018-01-08
@saboteur_kiev

99% that the problem is here: "include './system/db/connect.php';"
This command is executed relative to the current directory.
And what is the current directory when you call your php file from cron do you know?
Add some cd thread or specify the full path everywhere and try again.

A
Andrey, 2018-01-08
@VELIK505

include './system/db/connect.php';
write the full path /var/www/..../...../.../system/db/connect.php
or whatever you have there. and everything will work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question