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
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

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.