Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP CLI Cron job not running 1

Status
Not open for further replies.

JBellTek

Programmer
Jun 11, 2009
29
0
0
US
I've made a cron job that I am not getting results from. For testing, I entered the following line into crontab:

Code:
*/1 * * * * php /srv/var/[URL unfurl="true"]www/ads.bandmix.com/cron/check_pending.php[/URL] > /home/ubuntu/cronlogs/check_pending.txt

Now I can enter the following line into the command prompt and get exactly what I am expecting, however I am getting nothing every minute as I would expect from the cron:

Code:
php /srv/var/[URL unfurl="true"]www/ads.bandmix.com/cron/check_pending.php[/URL] > /home/ubuntu/cronlogs/check_pending.txt
 
Hi

JBellTek said:
PHP CLI Cron job not running
JBellTek said:
I've made a cron job that I am not getting results from.
Those two statements does not necessarily mean the same thing. Is it not running or not producing results ?

What should be the evidence of its done work ? Logs to file, moves/renames files after processing, sends mail ?

What happens inside the PHP script ? Query from database, transfer through network, incoming/outgoing mail processing, any operation that can make the script hang and wait ?

What kind of [tt]cron[/tt] implementation is that ? Has option to delay jobs if system resources are low ?


Feherke.
 
Sorry how terse I was, I was in a hurry.

When the script file executes correctly using this line:
Code:
php /srv/var/[URL unfurl="true"]www/ads.bandmix.com/cron/check_pending.php[/URL] > /home/ubuntu/cronlogs/check_pending.txt

then I get an email from the script, and this file is generated:
Code:
/home/ubuntu/cronlogs/check_pending.txt

When I execute the command from the command prompt, that is exactly what happens.

I added the other line to the crontab, assuming that it would do the same thing every 1 minute, however if there is any result to see I do not know where to find it as no email is sent and no file is generated.
 
One other comment I should make - this is not on a box that I set up, and this is the first cron job I have attempted on this box, so if there is anything in particular I need to do to make sure crons are functioning on this box, I may have missed it.
 
Hi

Is the [tt]cron[/tt] job executed with the same user's permissions ans from the command line ?

[tt]crond[/tt] should have its own logging, usually through [tt]syslog[/tt]. As far as I saw on Ubuntu [tt]crond[/tt] logs to /var/log/syslog. ( But check the exact location in /etc/syslog.conf. Note that messages with different priorities can be directed to different locations. ) See if you can find something mentioned there.
JBellTek said:
if there is anything in particular I need to do to make sure crons are functioning on this box, I may have missed it
Check if the daemon is running : [tt]/etc/init.d/cron status[/tt] ( Note that in case of specific init systems the services are handled in other ways. This is just the most common way. )


Feherke.
 
I think we may be getting somewhere here -

running /etc/init.d/cron status returns the following:
Code:
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service cron status

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the status(8) utility, e.g. status cron
cron start/running, process 599
You have new mail in /var/mail/ubuntu

In the research I have been doing, I did run across something about Upstart being used in Ubuntu, however it is not something I currently have any experience with. I am reading everything I can on upstart now. If anyone has advice on where the best place to look would be I'd love to hear it (I'm on upstart.mozilla.com now)
 
Ok, checking the mail file has revealed that the cron is firing once a minute, generating the following error message:

/bin/sh: php.exe: not found

I do not understand why I would be getting that message when the command is run from Cron but not from the command line.
 
Hi

Ouch. Sorry. I missed the evident :
Code:
*/1 * * * * [highlight]/usr/bin/[/highlight]php /srv/var/[URL unfurl="true"]www/ads.bandmix.com/cron/check_pending.php[/URL] > /home/ubuntu/cronlogs/check_pending.txt
Or wherever your [tt]php[/tt] interpreter is.


Feherke.
 
Interesting. I wondered about that.

What is the best way to find the current php install location? It was not where I expected to find it.
 
Hi

Use [tt]which[/tt] or [tt]whereis[/tt].

If neither is available, in Bash is another way : first start the [tt]php[/tt] ( no matter if you give it anything to do ), then the [tt]hash[/tt] shell builtin will show you the cached location where Bash found it.


Feherke.
 
feherke:

Yes, thank you. With your help I now have the final piece to the solution for my problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top