0

Okay, so I made a cronjob to run every two minutes and set it up to send me an email. Well, this is the cronjob. /home/sites/psychowars.com/public_html/cronjobs/energy_minute.php This is the email I receive.. nice:

/home/sites/psychowars.com/public_html/cronjobs/energy_minute.php: Permission denied

Well, this is the PHP file that's suppose to run.

<?php
require '../stats/users_stats.php';
    {
    if ($energy < $max_energy) {
    $sql = "UPDATE users SET energy=(energy + 1) WHERE id='".$id."'";
    $res = mysql_query($sql);
    }
    }
?>  

Every 2 minutes the user should recieve 1 energy if it's less than their max energy. Any solutions on what's wrong?

4

3 回答 3

0

你在这里有答案

$_SERVER 变量不是从 cron 作业中设置的。

于 2012-12-11T00:59:23.323 回答
0

尝试在脚本开始时手动设置 $_SERVER["DOCUMENT_ROOT"] 并且不要对 cronjob 脚本使用相对路径:

$_SERVER["DOCUMENT_ROOT"] = "/home/sites/psychowars.com/public_html";
require $_SERVER["DOCUMENT_ROOT"].'/stats/users_stats.php';
if ($energy < $max_energy) {
  $sql = "UPDATE users SET energy=(energy + 1) WHERE id='".$id."'";
  $res = mysql_query($sql);
}
于 2012-12-11T00:26:25.433 回答
0

如果仍然无法正常工作,您可以通过 www.guardiano.pm 外包您的 cronjob 并调用 http 帖子或向 yoursite.com/users_stats.php 获取请求,这样您就无需关心 cronjobs。如果您唯一需要的是恕我直言,您可以避免这种情况

于 2015-06-12T15:53:11.517 回答