Cronjob无法正常工作

I am using the below mentioned code to run cron job. I am running the cron job every minute. The cron file checks the whether there is a new data available for a particular user or not. If there is then just insert that into the database.

Problem I have checked in the SSH using tail -n 10 /var/log/cron command and it says that the cronjob ran a minute ago, which is great but it didn't entered the data in the database as there was a new data available. When I went directly on the URL it successfully added the data. Does anyone know what I might be doing wrong, any guidance will be great.

Cronjob Code

*/1 * * * * wget http://www.disciplinexgames.com/runkeeper/index.php >/dev/null 2>&1

PHP Code

$query = "Select * " .
         "from data_feeds " .
         "where username='mark@example.com' " .
           "and gadget_data_type='Weighin' " .
           "and gadget_data_type_id='3283123'";

$result = $dbCon->query($query);

//check if it is a new id..

if(mysql_num_rows($result) == 0){
    //Insert into database..
}

Few ideas:

  1. Use /usr/bin/wget instead of wget
  2. Put URL in quotation marks
  3. Redirect result to file like > ~/cron_debug.log 2>&1

I use a similar code CRON-STUFF wget http://page.com/path/script.php --delete-after >/dev/null 2>/dev/null to trigger cron PHP scripts so i think there isnt the problem.

Some ideas.

  • Did you put in the MySQL connection stuff in the stand alone script (one think i mostly forget)
  • Did you executed the command without cron and does it do the job? If yes are there some permission (file / user) problems with the script?