#1
  1. No Profile Picture
    Not as smart as I should be.
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2005
    Posts
    66
    Rep Power
    10

    Permissions Help for Linux based web server


    I have a PHP script that uses MYSQLDUMP and TAR to generate a zipped backup file of my database. Then it uploads that file to dropbox.

    When I was testing it, I had the PHP script in a directory that I could see from a browser. Ideally now I want to move the script outside of httpdocs directory

    Now that it's all tested I want to use CRONTAB to run the script nightly.

    The problem is, (I think) the script, now that it's being run via the PHP command rather than through Apache, it's running as a different user.

    The result of this is, the MYSQLDUMP command cannot create the output file anymore. (even running the script from the dir inside httpdocs where it was previously working fine.)

    The directory I want to to save in is set to 777. (The same dir as it was using when I ran the script manually)

    If I try the same MYSQLDUMP command via an SSH connection then it works fine. It will create the file in the place I want. It's just that when the MSQYDUMP is done through PHP it's not able to output to that directory.

    Am I missing something very obvious here?
  2. #2
  3. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,453
    Rep Power
    4539
    Could be a number of things. Cron jobs won't normally inherit any environment settings (i.e., no PATH) so make sure you use full paths to all scripts and files.

    As long as you have cli php installed, try running the php script itself from the command line and see what happens.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,484
    Rep Power
    1752
    Is it running from the crontab of the same user as is used to run the web server?

    Comments on this post

    • aitken325i agrees
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc

IMN logo majestic logo threadwatch logo seochat tools logo