SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 37 of 37

Thread: Cronjob

  1. #26
    SitePoint Addict
    Join Date
    Feb 2001
    Location
    Shanghai, China
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what do you mean?

  2. #27
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Since you redirect to dev/null, the results is not available to see or report.
    So try this under telnet
    php3 /home/username/www/folder/file.php3

    and see what you get.
    Are you sure that the PHP binary is "php3" and not just "php"?
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  3. #28
    SitePoint Enthusiast RandMan's Avatar
    Join Date
    Mar 2001
    Location
    Crossville, TN USA
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    smorb

    Have you solved the problem yet? I had the same situation, but I solved it.

  4. #29
    SitePoint Addict
    Join Date
    Feb 2001
    Location
    Shanghai, China
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No. But I didn't try for a while. What exactly was your problem and how did you solve it? Thx, smorb

  5. #30
    SitePoint Enthusiast RandMan's Avatar
    Join Date
    Mar 2001
    Location
    Crossville, TN USA
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My program would update an existing file I had created and uploaded. When I would run the program from my browser it would work fine. However, when I ran it from cron I received a permission denied error.

    To solve problem I deleted the file and let the program create the file while running as a cron.

    I used the syntax:

    php /path/to/file.php /dev/null

    From what I can understand, the ownership of the file is what is under question. A file created while running via the browser has one owner. A file created while running via cron has a different owner.

    Hope this helps you.

  6. #31
    SitePoint Addict
    Join Date
    Feb 2001
    Location
    Shanghai, China
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ahh, could you explain me what you mean with
    I deleted the file and let the program create the file while running as a cron.

  7. #32
    SitePoint Enthusiast RandMan's Avatar
    Join Date
    Mar 2001
    Location
    Crossville, TN USA
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, it was late when I wrote that last night.

    My script accesses the db and pulls in a random quote. It then writes ( fopen ('quote.htm','w') ) the quote and formatting HTML to a file "quote.htm". This is my quote of the day file I suck (include) into my main page.

    Running the script from my web browser the first time created the file "quote.htm". Subsequent executions of the script from the browser just wrote over the old file, creating a new file.

    Running the script from cron gave an error. Cron does not have permission to write over the file "quote.htm" because it already exists and is owned by another process.

    I deleted the file "quote.htm", the created file. I then allowed cron to run my script. The first time it ran it created a file "quote.htm". Cron then became the owner of that file. Subsequent cron executions work because cron has permission, through ownership, to alter the file "quote.htm".

    Be sure to use the syntax described. php must be the first thing on the command line. It tells to use PHP to process the file.

    php /path/to/file.php /dev/null

    This is third day running for my cron. Every night at midnight it creates a new quote of the day. Hope this helps you out.

  8. #33
    SitePoint Addict
    Join Date
    Feb 2001
    Location
    Shanghai, China
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, no that didn't solve my problem. Could you show me your "copy-the-dynamic-to-no-dynamic-page" skript. Maybe the problem is not the cron job but this skript. Do you know any way to check if a cron job as been executed ( a kind of log-file ) ?

  9. #34
    SitePoint Enthusiast RandMan's Avatar
    Join Date
    Mar 2001
    Location
    Crossville, TN USA
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Support at my web host sent me the following code:
    Code:
    0 0 * * * lynx -dump http://domain.com/quote.php >> /dev/null
    However I have not tried it, nor di I need to since my cron works. You might want to try this.


    The following is the complete script I execute with my cron:
    Code:
    <?php
    
    include("/path/db.inc");
    db_connect();
    
    $path = "/path/quoteinc.htm";
    
    $query = "SELECT quote FROM quotes,lookup WHERE cid='88' AND qid=id ORDER BY RAND() LIMIT 1";
    $result = mysql_query($query);
    
    $quotes = mysql_fetch_row($result);
    
    if ( !$quotes ) { die("Error getting results"); }
    
    $quote = split("-> ",$quotes[0]);
    
    $string = "<table align=\"center\" width=\"420\" border=\"0\" frames=\"border\" rules=\"none\" cellspacing=\"0\">";
    $string .= "<tbody><tr><td align=\"justify\" style=\"text-align: justify\">$quote[0]</td></tr>\n";
    $string .= "<tr><td align=\"right\">$quote[1]</td></tr></tbody></table>";
    
    $fp = fopen($path,"w");
    fputs($fp,$string);
    fclose($fp);
    
    ?>
    The path information has been edited for security purposes.

    If you run this scrip from your web browser, it is imperative that you delete the old output file before you execute this script from cron. Failure to delete that file will cause an error.

  10. #35
    SitePoint Enthusiast RandMan's Avatar
    Join Date
    Mar 2001
    Location
    Crossville, TN USA
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cron sends an email when it executes. If you have an error it will tell you what it is. If it executes successfully it will let you know it has run.

    Use your control panel and check your system email. Ask your support dept where you will receive notifications.

  11. #36
    SitePoint Addict
    Join Date
    Feb 2001
    Location
    Shanghai, China
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You mean I will get an e-mail every time cron runs successfully? That means I should get 24 mail a day on my cron-job running once a hour?
    I got error messages, so the e-mail adress is correct.

  12. #37
    SitePoint Enthusiast RandMan's Avatar
    Join Date
    Mar 2001
    Location
    Crossville, TN USA
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes. But, your system may vary from mine. This is the email sent after last cron:
    Date: 5/14/2001 00:00:01 -0400
    From: root@admin.server.net (Cron Daemon)
    To: account@admin.server.net
    Subject: Cron <account@admin> php /home/account/public_html/path/quote.php /dev/null

    X-Powered-By: PHP/4.0.4pl1
    Content-type: text/html
    If you are still having problems getting your to work perhaps the problem lies in the script. Make sure you are using absolute paths.


Bookmarks

Posting Permissions

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