Results 1 to 3 of 3
  1. #1
    Junior Member
    Join Date
    Dec 2003
    Posts
    6

    Default Setting up a cron for a PHP script

    I have a test script here, to try and get a cron job running

    function db_connect($database)
    {
    mysql_connect("localhost","root","password");
    mysql_select_db($database);
    }

    db_connect("database_name");
    mysql_query("INSERT INTO stuff (id) VALUES ('1')");

    The script works fine, I loaded it directly and it updates the database. However I want a cron job to execute the script.....

    I have tried these alternatives, to update at whatever minutes are a few minutes ahead of me trying them

    30,31,32,33 * * * * /ftp/usr/lib/php /var/www/html/global_functions.htm 2>&1 > /dev/null
    30,31,32,33 * * * * /ftp/usr/lib/php /var/www/html/global_functions.htm
    30,31,32,33 * * * * /var/www/html/global_functions.htm 2>&1 > /dev/null

    However, none of them updated the table. Has anyone else here used a cron successfully? I'd appreciate some pointers.

    Thanks.

  2. #2
    Senior Member SJP's Avatar
    Join Date
    Aug 2003
    Location
    Orcas, Wa
    Posts
    205

    Default

    I use cron to launch a perl script every 4 hours. Have you gotten the OK from the technical support people? That's what I did when I began. Cron isn't enabled out of the box.

    SJP

  3. #3
    Junior Member
    Join Date
    Dec 2003
    Posts
    6

    Default

    Hi, thanks for posting.

    Yes it is enabled, I had sent an e-mail to support they were not too helpful, saying that the syntax in my cron was "obviously" wrong ) .... referring to me having 1,2,3,4,5 in the minute field which AFAIK works. He also mentioned they don't provide assistance with this sort of thing.

    I'll ask them again in the meantime. Thanks for taking the time to post, and again, any pointers appreciated.

    //added

    Got confirmation it was already installed and working...AND got it working also. I was pointing to the errr...wrong php

    /bin/php is the path I should have pointed to, gracias

Similar Threads

  1. Getting php script to run as cron
    By esiason14 in forum Solutions
    Replies: 9
    Last Post: 04-23-2007, 04:18 PM
  2. exec(), popen(), etc. for executing a php script
    By Tlanuwa in forum PHP / MySQL
    Replies: 3
    Last Post: 09-18-2006, 06:25 PM
  3. cron wget php
    By mayjune2004 in forum General Discussion
    Replies: 2
    Last Post: 01-10-2006, 11:03 AM
  4. Need Cron Job Primer (I think!)
    By ccwebb in forum PHP / MySQL
    Replies: 3
    Last Post: 10-02-2005, 01:48 PM
  5. Cron PHP Script - Read file problems
    By grim in forum PHP / MySQL
    Replies: 2
    Last Post: 07-12-2004, 11:45 AM

Posting Permissions

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