Jump to content
MakeWebGames

Cron file help


rednspirited

Recommended Posts

i have been searching the site for info but after hours of reading i decided to make this post. i have tried different ways but cant seem to make my cron files to work.  i am only posting the minute file cause its the shortest and the code line is pretty much the same for each. any help i will be greatful for . thank you 

 

require_once(dirname(__FILE__) . "/../mysqli.php");
$cron_code = '* * * * * curl public_html/cron_minute.php?code=672bb9f5a0b168da99fbbf74980175ecd';
if ($argc == 2) {
    if ($argv[1] != $cron_code) {
        exit;
    }
} else if (!isset($_GET['code']) || $_GET['code'] !== $cron_code) {
    exit;
}
mysqli_query("UPDATE users SET hospital=hospital-1 WHERE hospital>0", $c);

 

Link to comment
Share on other sites

* * * * * curl public_html/cron_minute.php?code=672bb9f5a0b168da99fbbf74980175ecd

This needs adding to your crontab you may have to add other file directories to the beging but there should be documentation in your crontab for this

*Edit how ever you formatted that code has broken the code section and won't let me post it as code 

Link to comment
Share on other sites

You've passed a cron command to a variable that shouldn't be there.
Change your $cron_code var to hold, funnily enough, your cron's code (an override token that allows it to run).

$cron_code = '672bb9f5a0b168da99fbbf74980175ecd';


You may also wish to generate a new cron token as that one is now public - note that, if you do, you will need to update the cron commands with the new token too

  • Like 1
Link to comment
Share on other sites

You haven't passed the cron token to your command either.

So, the top of your cron file (using the snippet you posted as reference)

require_once dirname(__DIR__).'/mysqli.php';
$cron_code = '672bb9f5a0b168da99fbbf74980175ecd';
if ($argc == 2) {
    if ($argv[1] != $cron_code) {
        exit;
    }
} else if (!isset($_GET['code']) || $_GET['code'] !== $cron_code) {
    exit;
}


And your command should be

php /home/battlefo/public_html/crons/cron_fivemins.php code=672bb9f5a0b168da99fbbf74980175ecd

 

Link to comment
Share on other sites

1 hour ago, Magictallguy said:

You haven't passed the cron token to your command either.

So, the top of your cron file (using the snippet you posted as reference)

require_once dirname(__DIR__).'/mysqli.php'; $cron_code = '672bb9f5a0b168da99fbbf74980175ecd'; if ($argc == 2) { if ($argv[1] != $cron_code) { exit; } } else if (!isset($_GET['code']) || $_GET['code'] !== $cron_code) { exit; }


require_once dirname(__DIR__).'/mysqli.php';
$cron_code = '672bb9f5a0b168da99fbbf74980175ecd';
if ($argc == 2) {
    if ($argv[1] != $cron_code) {
        exit;
    }
} else if (!isset($_GET['code']) || $_GET['code'] !== $cron_code) {
    exit;
}


And your command should be

php /home/battlefo/public_html/crons/cron_fivemins.php code=672bb9f5a0b168da99fbbf74980175ecd


php /home/battlefo/public_html/crons/cron_fivemins.php code=672bb9f5a0b168da99fbbf74980175ecd

 

That's how it reads but they dont work

Link to comment
Share on other sites

Alright, let's try a slightly different method.
Replace

if ($argc == 2) {
    if ($argv[1] != $cron_code) {
        exit;
    }
} else if (!isset($_GET['code']) || $_GET['code'] !== $cron_code) {
    exit;
}

with

if (isset($argv)) {
    $args = parse_str($argv[1], $param);
    $_GET['code'] = $param['code'];
}
if(!array_key_exists('code', $_GET) or $_GET['code'] != $cron_code) {
    exit;
}

 

  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...