Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a script which reads files from a database, finds them in a directory and copies them to another directory as part of an upload system. The process is: 1. User uploads a file through ftp to /home/uploaduser 2. User enters info into a mysql database 3. A cronjob (download.php) polls the database, finds the uploaded file name 4. Same cronjob checks /home/uploaduser for the filename and copies the file to another directory

If I run download.php from the command line, the script works. If I run it from crontab, it fails to find the file with file_exists().

Here's the cronjob: */1 * * * * php /home/downloads/cron-scripts/download.php >/dev/null 2>&1

I've tried changing ownership of the files to the user who runs the cronjob, with no difference.

The cronjob is installed running: crontab -e as the user who also runs the script. The user who runs the script is in the uploaduser group, and the uploaduser group file permissions are 664.

share|improve this question
    
I've sent the output of the cronjob to a log file, but it doesn't print anything interesting out, which makes sense, because my script exits when the file_exists() function fails. It would seem that it's a permissions issue, since when running the same script from the command line, the file_exists() check succeeds. –  Aaron Craig Feb 11 '10 at 7:24

2 Answers 2

do you have something in your scripts which depends on environment settings? the environment cron runs with is normally different from your user environment.

redirect the output of your script to a log file instead of /dev/null to get an error message.

share|improve this answer
  1. Try giving the absolute path for PHP executable like /usr/bin/php
  2. Try redirecting the output to some file so that you can see the output
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.