Forum Moderators: coopster

Message Too Old, No Replies

PHP script won't run as CRON job

         

kristo5747

5:41 pm on Nov 16, 2010 (gmt 0)

10+ Year Member



Gurus,

I have coded for my client a PHP script that performs some extensive data munging on text files he creates.

Code is complete and I have now to automate the script. Problem is that it seems to *only* run manually. I won't run as CRON job.

This is what I have tried with "#!/usr/bin/php -q" in the header of my script:

00 1 * * * /usr/bin/php -q /HDDLogs/HDDProcess.php >>/HDDLogs/HDDProcess.log 2>&1


The log file does get created but is empty. I tried removing the -q for quiet mode: no difference. Still did not run.

Apache 2.0 and PHP 5.3 is installed on this server. I fully own the directory with my code and the data files are located.

Any idea?

Thanks,

Al.

jamie

9:45 am on Nov 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hi kristo,

if you add "#!/usr/bin/php -q" to the top of the script then you don't need to run the script as user php. it can simply run as an executable script, for which you need to set chmod 744 (or chmod u+x).

so the cron job would be:

00 1 * * * /HDDLogs/HDDProcess.php >>/HDDLogs/HDDProcess.log 2>&1

however if you use your original crontab line which runs the script as user /usr/bin/php, then remove the "#!/usr/bin/php -q" from the header of the script. you don't need both.

if it still doesn't work it is probably a permissions problem. chmod the php file and the log file to 777 to see if that works. if it does, then you can test with changing the owner and permissions to get it down to the tightest permissions possible.

hth