July 18th, 2012, 08:24 AM
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?
July 18th, 2012, 06:28 PM
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.
I've never been able to appreciate the sublime arrogance of folks who feel they were put on earth just to save other folks from themselves .." - Donald Hamilton
July 19th, 2012, 04:21 AM
Is it running from the crontab of the same user as is used to run the web server?
Comments on this post
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