SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot
    Join Date
    Dec 2005
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP daemon for cron jobs on MySQL 5?

    Can't find anything on the Google, so thought I'd see if anyone here could help. A client's server runs PHP v5 just fine through the web browser, but when I try to execute a PHP script through SSH or a cronjob, I get an error saying it can't connect to the database.

    I asked the server administrator about this, and she just said there was a problem with the mysqld5 socket, and that I should run the PHP script as a daemon that loops every 60 seconds. Any input?
    Kiopa Software -- Demo Now Online! Check it out!
    Goal: Consolidate all data & tools you use on a daily basis.
    Grand opening special, licenses FREE for a limited time.

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Does the php.ini file that the CLI of PHP is using have the mysql extensions loaded?
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  3. #3
    SitePoint Wizard Hammer65's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln Nebraska
    Posts
    1,160
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A daemon would just duplicate what cron does. Use ssh to invoke PHP with the -m option to view all loaded modules. If MySQL isn't there, then that is where you problem is.

  4. #4
    SitePoint Zealot
    Join Date
    Dec 2005
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, mySQL extension is loaded just fine. Everything works 100% via the web browser, but when I try to execute a script via SSH or crontab, I get an error saying it can't connect to the database. The server admin says it's some socket issue with mySQL v5, and it can be solved by me running a PHP script as a daemon. No idea how that's going to solve the problem, but that's what she says.

    And ideas or advice?
    Kiopa Software -- Demo Now Online! Check it out!
    Goal: Consolidate all data & tools you use on a daily basis.
    Grand opening special, licenses FREE for a limited time.

  5. #5
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The ini-file may be different for the CLI version of PHP, than the browser-version.

    Cron usually runs scripts as a different user, than the http-server does; That might restrict access as well.

  6. #6
    SitePoint Wizard Hammer65's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln Nebraska
    Posts
    1,160
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That makes no sense to me. I admit I don't know everything about UNIX networking, but you may be able to play with the arguments of mysql_connect to get it to work. Specify a port, use 127.0.0.1 instead of localhost. PHP running as a damon wouldn't be any different than running as a one time script. It may depend on what user it is running under, but if PHP will connect using the Apache user, I can't imagine how it would make a difference what user the CLI version runs under.


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
  •