cron not working when calling php script with mysql on linux box

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dburdick@isound.com

    cron not working when calling php script with mysql on linux box

    I was referred to this forum as this may be a php specific problem.
    Some kind of configuration problem maybe.

    I have some php files that connect to a mysql database and are run as
    cron jobs.

    The scripts work fine when run via the command line as root, but when
    run via the cron they cause a mysql connection error.

    Call to undefined function: mysql_pconnect( )

    I have found some info on this and tried many things but none of them
    are working.

    Does this have something to do with setting the appropriate environment
    in php
    script? I read something about that but am not sure how or what to do.

    Please help!!!

    Thank you!

  • Jerry Stuckle

    #2
    Re: cron not working when calling php script with mysql on linuxbox

    dburdick@isound .com wrote:
    I was referred to this forum as this may be a php specific problem.
    Some kind of configuration problem maybe.
    >
    I have some php files that connect to a mysql database and are run as
    cron jobs.
    >
    The scripts work fine when run via the command line as root, but when
    run via the cron they cause a mysql connection error.
    >
    Call to undefined function: mysql_pconnect( )
    >
    I have found some info on this and tried many things but none of them
    are working.
    >
    Does this have something to do with setting the appropriate environment
    in php
    script? I read something about that but am not sure how or what to do.
    >
    Please help!!!
    >
    Thank you!
    >
    Could be your environment, PHP setup or any of about a dozen different
    things.

    One big difference is the cron job is probably running under a different
    user, with different privileges - both for MySQL and PHP. It could even
    be using a different php.ini - depending on the environment set up for
    that user.

    Did you try asking your sysadmin? That's where I would start -
    otherwise you may spend days trying to chase down all the various
    possibilities.

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • dburdick@isound.com

      #3
      Re: cron not working when calling php script with mysql on linux box


      dburdick@isound .com wrote:
      I was referred to this forum as this may be a php specific problem.
      Some kind of configuration problem maybe.
      >
      I have some php files that connect to a mysql database and are run as
      cron jobs.
      >
      The scripts work fine when run via the command line as root, but when
      run via the cron they cause a mysql connection error.
      >
      Call to undefined function: mysql_pconnect( )
      >
      I have found some info on this and tried many things but none of them
      are working.
      >
      Does this have something to do with setting the appropriate environment
      in php
      script? I read something about that but am not sure how or what to do.
      >
      Please help!!!
      >
      Thank you!

      I believe i have narrowed this down.

      I ran the same identical script with phpinfo() in it from 2 different
      locations.

      1 I ran from the command line and 1 I ran from the crontab.

      The one that i ran from the crontab didn't not have mysql support
      enabled.

      Looks like that is the problem!

      Why are these different?
      How do i compile that php version with mysql support?

      I believe this should solve this issue.

      Thanks!

      Comment

      • Jerry Stuckle

        #4
        Re: cron not working when calling php script with mysql on linuxbox

        dburdick@isound .com wrote:
        dburdick@isound .com wrote:
        >
        >>I was referred to this forum as this may be a php specific problem.
        >>Some kind of configuration problem maybe.
        >>
        >>I have some php files that connect to a mysql database and are run as
        >>cron jobs.
        >>
        >>The scripts work fine when run via the command line as root, but when
        >>run via the cron they cause a mysql connection error.
        >>
        >>Call to undefined function: mysql_pconnect( )
        >>
        >>I have found some info on this and tried many things but none of them
        >>are working.
        >>
        >>Does this have something to do with setting the appropriate environment
        >>in php
        >>script? I read something about that but am not sure how or what to do.
        >>
        >>Please help!!!
        >>
        >>Thank you!
        >
        >
        >
        I believe i have narrowed this down.
        >
        I ran the same identical script with phpinfo() in it from 2 different
        locations.
        >
        1 I ran from the command line and 1 I ran from the crontab.
        >
        The one that i ran from the crontab didn't not have mysql support
        enabled.
        >
        Looks like that is the problem!
        >
        Why are these different?
        How do i compile that php version with mysql support?
        >
        I believe this should solve this issue.
        >
        Thanks!
        >
        Which php.ini file is each one using? The version of PHP? Perhaps you
        have two copies of php on your system.

        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        Working...