Jump to content

PHP script won't run as CRON job


kristo5747

Recommended Posts

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?? :wtf:

 

Thanks,

 

Al.

Link to comment
https://forums.phpfreaks.com/topic/218868-php-script-wont-run-as-cron-job/
Share on other sites

try php -f /HDDLogs/HDDProcess.php

Is cron logging enabled? probably piping to syslog if it is.

Does syslog show a successful run?

Your script doesn't rely on any environment variables does it? cron's execution wont load up any of your shell variables from .login, .bash, etc.

/usr/bin/php is php-cli, yes? though I dont think it should make a difference in this situation

 

... I'm running out of ideas

I am officially a moron. :facewall:

 

I had 2 includes (in a \lib directory) in my script. CRON did not known anything about these, thereby explaining why my script never ran.

 

I created a bash script wrapper that navigates into that directory before launching the script.

 

It works now.

 

I am officially a moron. :facewall:

 

I had 2 includes (in a \lib directory) in my script. CRON did not known anything about these, thereby explaining why my script never ran.

 

I created a bash script wrapper that navigates into that directory before launching the script.

 

It works now.

 

That was my gut feeling, that's what error reporting would have told you :)  Also, rather than a bash script you can use absolute path names for the includes.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.