2

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 as CRON job. PHP File is chmod-ed 755.

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.

In case you're wondering, my script never calls a URL.

Any idea??

Thanks,

Al.

7
  • 1
    @user484638 - remove the log file, and see it is has been re-create? If so, meaning your PHP is just yet to finsh ps auwx | grep HDDProcess.php to check is still running Commented Nov 16, 2010 at 17:53
  • I tried what you suggest. The log file does NOT get recreated. Commented Nov 16, 2010 at 18:05
  • @Paulo: Correct. the file HDDProcess.log is empty. I get CRON mail with an empty body (?). No message. And it is a user crontab where I run a dozen bash scripts without problem. Commented Nov 16, 2010 at 18:23
  • 2
    Do you have any "include('foo')" with relative paths? If so you can try to write a shell script that first CD to the script directory and then calls your PHP script. Commented Nov 16, 2010 at 18:27
  • @Paulo: ((smacking myself)) You are correct!! I do have two includes with relative paths. I created a shell script wrapper that navigates into the directory before calling the script. Obrigado muito! Commented Nov 16, 2010 at 18:37

1 Answer 1

2

I think it should be:

"... /usr/bin/php -q -f /HDDLogs/HDDProcess.php ..."

or

"... /usr/bin/php -q < /HDDLogs/HDDProcess.php ...".

Sign up to request clarification or add additional context in comments.

3 Comments

Yes, you need the -f flag to execute a file from the command line. From man php, "-f file Parse and execute file"
I tried both your suggestions. Does not work: php script never kicks off.
/HDDLogs/HDDProcess.log is empty? Any cron mail at inbox? The script runs when you "su" to the cronjob owner? Is it the system crontab at /etc/crontab or a user crontab?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.