Cronjob not work well

Username (e.g. epiz_XXX) or Website URL

Other Information

My cronjob cannot work well.
cronjob set to run every 10 min:

In this cronjob, I set a check message that if it runs it will record the result in mySQL database. I found that it did not work for every 10 minutes, but works randomly…

How to fix this?

Maybe can you share the contents of TenMinuteCron.php for debugging?

(Just censor all sensitive data)

If im not mistaken, it seems that the problem is on PHP code.

1 Like

Cron Job isn’t very efficient here. That may be the problem.

The Code’s Here:

  10 Minute Cron Job				
  Should be run very 10 minutes	
  01,11,21,31,41,51 * * * * wget -qO- >/dev/null 2>&1

// file configs //

// db connectors and functions //
$db = new Database();

// account functions //


// * Get All Active BFX Accounts     * //
// * Create Account Objects for them * //

// check that the crons database exists //
$cronsTableSQL = '
	CREATE TABLE IF NOT EXISTS `'.$config['db']['prefix'].'CronRuns` (
	  `id` int(11) NOT NULL AUTO_INCREMENT,
	  `cron_id` tinyint(1) NOT NULL,
	  `lastrun` datetime NOT NULL,
	  `details` varchar(256) NOT NULL,
	  PRIMARY KEY (`id`)
$rt = $db->iquery($cronsTableSQL);

$userIds = $db->query("SELECT id from `".$config['db']['prefix']."Users` WHERE status >= '1' AND ( status != '2' AND  status != '8' )  ORDER BY id ASC");
foreach($userIds as $uid){
	/* Run the bot to update all pending loans according to account settings */	
	$act = new Accounts($uid['id']);
	$bfx = new Bitfinex($uid['id'], $act->apiKey, $act->apiSec);
	// mark it in the crons table so we know its working
	$cronUpdates = $db->iquery("INSERT into `".$config['db']['prefix']."CronRuns` (`cron_id`, `lastrun`, `details`) VALUES ('2', NOW(), 'Updated User ".$uid['id']." Current Loans')");	


The cron scheduling is a bit… weird. Can you please try setting the corn job up again, but this time with “Hours” set to 1 and see what that does to the schedule?


But I need this cron to be done once per 10 min. I use right now and it works.

Like I said: the scheduling is weird and many not do what you expect.

What I meant is that if you change the hours to 1, then it may just work the way you wanted to. Does it make sense? Not at all. But that’s what it is.


This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.