dongyuli4538 2013-06-20 12:03
浏览 40

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..
}
  • 写回答

2条回答 默认 最新

  • douzhao6584 2013-06-20 12:08
    关注

    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
    评论

报告相同问题?

悬赏问题

  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试