Frage

Very strange things happening in phpMyAdmin (mySQL)....

The Situation:
I have a table with only one field that holds an INT value called 'count'. count was originally set to 0. A cron job calls a php script every hour which increments 'count' by one (SET count = count + 1).

The Problem:
The problem can be observed when I open the table in phpMyAdmin, and then immediately refresh the browser: I can see that 'count' has been incremented like 20 times in under a second. Leaving it alone for a minute and then refreshing the browser again shows that it's been incremented hundreds of more times! Is some endless loop somewhere calling my cron job and incrementing 'count'? (Don't think so because I updated crob php script to email me when its called, and I'm getting no calls...)

Has anything like this ever happened to anyone?

The CRON String:

*/15 * * * * /usr/bin/php -q /home/account_name/cron/cron.php test

The php Script:

<?php

class TestCommand extends CConsoleCommand {
    private $connection;

    public function run($args) {
        // Increment counter
        $this->connection=Yii::app()->db;
        $sql="UPDATE count_converts SET count=count+1 WHERE id=1";
        $command=$this->connection->createCommand($sql);
        $command->execute();
    }
 }

?>

UPDATE:
Mystery solved: Found out this was due to a bad nested for loop somewhere else (both loops used $i)...

War es hilfreich?

Lösung

Why id there a <br /> and a line break in your cron string? Change it to

*/15 * * * * /usr/bin/php -q /home/account_name/cron/cron.php test

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top