Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Sep 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Crontab Execution Problem

    Hi Guys
    Here is my php file that i execute through crontab setting

    PHP Code:
    <?php
    include "register_globals.php";

    $sql_user='******'// user mysql
    $sql_password='******'// password mysql 4 user

    $blas=curl_init();

    $db=mysql_connect('localhost',$sql_user,$sql_password);
    mysql_select_db("blast",$db);
    $rez=mysql_query("SELECT s_time,s_query_last,s_cdate,u_mail FROM search, users WHERE s_user=u
    _id"
    );
    while(list(
    $response_time,$my_query,$cdate,$mail_respons_addr)=mysql_fetch_row($rez)){
    #     $file_mail_respons = fopen('/tmp/.mailrespons.txt', 'w');
         
    $file_mail_respons fopen('mailrespons.txt''w');
         
    $flag=false;
      if(
    $my_query!=''){
         switch(
    $response_time){
              case 
    '0': break;
              case 
    '1':$flag=true; break;
              case 
    '2':
                if(
    date('w')==='1'){
                
    $flag=true;
                }
                 break;
              case 
    '3':
                if(
    date('d')==='01'){
                
    $flag=true;
                }
                 break;
             }
        }
     if(
    $flag){
     
    $blas=curl_init();
    # curl_setopt($blas,CURLOPT_URL,"http://www.ncbi.nlm.nih.gov/blast/Blast.cgi");
    # curl_setopt($blas,CURLOPT_POSTFIELDS,trim($my_guery_h));

     
    curl_setopt($blas,CURLOPT_URL,"http://www.ncbi.nlm.nih.gov/blast/Blast.cgi");
     
    curl_setopt($blas,CURLOPT_POSTFIELDS,$my_query);
     
    curl_setopt($blas,CURLOPT_FILE,$file_mail_respons);
     
    curl_exec($blas);
     
    curl_close($blas);
     
    fclose($file_mail_respons);

         
    $file_mail_respons fopen('mailrespons.txt''r');
    #    $file_mail_respons = fopen('/tmp/.mailrespons.txt', 'r');
        
    $mail_respons_text fread($file_mail_respons,100000);
        
    fclose($file_mail_respons);
    #$temp=$mail_respons_text;
    $temp_response=str_replace("<form action=\"Blast.cgi\"","<form action=\"http://www.ncbi.nlm.nih.gov/blast/Blast.cgi\"",$mail_respons_text);
    #    echo $mail_respons_addr."
    ".$mail_respons_text."
    ",$my_query,"
    ";
    #   Mail($mail_respons_addr,"",$mail_respons_text);
       Mail($mail_respons_addr,"",$temp_response);
    #echo $temp_response;
     }
    }
       mysql_close($db);
    exit;
    ?>
    My problem is that in my site when i choose this file to run daily, i get results in my email around 60 in a day same email. Why doesnt it send me just one email instead of sending 60 at a time?
    My crontab setting for running this file is :
    * 0 * * * /home/chandhs/blast_site/myblast4cron.php

    Pls help.
    Last edited by Spookster; 10-26-2006 at 03:49 AM. Reason: Added [php] [/php] tags

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts
    I removed your database login info. I wouldn't recommend posting that in the future. Also please use the forum php tags when posting code.

    Anyways are you asking why is it sending you 60 emails each with a response verses sending you one email with 60 responses? Probably because you have the mail command inside the while loop. It will generate a new email for each iteration of the loop.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •