Log in

View Full Version : Cron Job help


KatFennec
05-27-2017, 01:45 AM
I'm trying to set up cron jobs to decrease a stat several times a day on each adoptable, but I'm running into some trouble and I'm not sure if it's the cron job itself or the PHP. Note that I'm specifically interested in Cron Jobs, not scheduled tasks.



cron.php
<?php
class CronController extends AppController{

public function __construct(){

}

public function index(){

}

public function lowerFullness() {
$mysidia = Registry::get("mysidia");
$mysidia->db->update("owned_adoptables", array("fullness" => -10));
}

}
?>

Dinocanid
05-28-2017, 07:31 PM
I wanted to rip my hair out so bad trying to figure this out a long time ago, but I found the answer a few minutes ago!

There is actually nothing wrong with your cron.php. When you create the cronjob in cPanel, the command has to be:
curl http://YOURURL/cron/function
So replace 'function' with whatever function you are trying to run in cron.php and it should work.

EDIT: Also apparently using math right there with UPDATE will not work. See here (http://www.mysidiaadoptables.com/forum/showthread.php?t=5363&highlight=subtract) for a fix

KatFennec
05-28-2017, 11:13 PM
That did it, thanks for the help!