Jump to content

Cron / Crontab / Memcache / Memcached not working properly


Recommended Posts

Hi,

 

I followed:

http://yoodey.com/comment/10825

to install memcache / memcached on ubuntu 12.04 hosted by Amazon EC2 (I have full admin right to the server)

 

It is working:

http://ec2-54-247-22...com:81/test.php

 

shows:

<?php
$memcache = new Memcache;
$memcache->connect('127.0.0.1', 11211) or die ("Could not connect"); //connect to memcached server
$mydata = "Chache me Ruzdi"; //string to be cached
$memcache->set('ruzdi', $mydata, false, 100); //add the data to memcached server
$cacheData = $memcache->get('ruzdi'); //retrieve your data from memcache server
var_dump($cacheData); //dump you data which is retrived from memcached server
?>

 

However, prestashop cron seems not working [i just re-initialised it and activated the test task again]

 

The problem seems to be on Prestashop side as every minute I can see:

You have new mail in /var/ubuntu/mail

  • with * * * * * echo 'ok

From ubuntu@ip-10-59-10-232.eu-west-1.compute.internal  Wed Jul 18 13:42:02 2012
Return-Path: <ubuntu@ip-10-59-10-232.eu-west-1.compute.internal>
Received: from ip-10-59-10-232.eu-west-1.compute.internal (localhost [127.0.0.1$
	by ip-10-59-10-232.eu-west-1.compute.internal (8.14.4/8.14.4/Debian-2ub$
	for <ubuntu@ip-10-59-10-232.eu-west-1.compute.internal>; Wed, 18 Jul 20$
Received: (from ubuntu@localhost)
	by ip-10-59-10-232.eu-west-1.compute.internal (8.14.4/8.14.4/Submit) id$
	for ubuntu; Wed, 18 Jul 2012 13:42:01 GMT
Date: Wed, 18 Jul 2012 13:42:01 GMT
Message-Id: <201207181342.q6IDg1IU028985@ip-10-59-10-232.eu-west-1.compute.inte$
From: root@ip-10-59-10-232.eu-west-1.compute.internal (Cron Daemon)
To: ubuntu@ip-10-59-10-232.eu-west-1.compute.internal
Subject: Cron <ubuntu@ip-10-59-10-232> echo 'ok'
Content-Type: text/plain; charset=ANSI_X3.4-1968
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/ubuntu>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=ubuntu>
ok

  • with * * * * * php -f /var/www/site2/modules/cron/cron_crontab.php

From ubuntu@ip-10-59-10-232.eu-west-1.compute.internal  Wed Jul 18 13:04:01 2012
Return-Path: <ubuntu@ip-10-59-10-232.eu-west-1.compute.internal>
Received: from ip-10-59-10-232.eu-west-1.compute.internal (localhost [127.0.0.1$
	by ip-10-59-10-232.eu-west-1.compute.internal (8.14.4/8.14.4/Debian-2ub$
	for <ubuntu@ip-10-59-10-232.eu-west-1.compute.internal>; Wed, 18 Jul 20$
Received: (from ubuntu@localhost)
	by ip-10-59-10-232.eu-west-1.compute.internal (8.14.4/8.14.4/Submit) id$
	for ubuntu; Wed, 18 Jul 2012 13:04:01 GMT
Date: Wed, 18 Jul 2012 13:04:01 GMT
Message-Id: <201207181304.q6ID41O4028284@ip-10-59-10-232.eu-west-1.compute.inte$
From: root@ip-10-59-10-232.eu-west-1.compute.internal (Cron Daemon)
To: ubuntu@ip-10-59-10-232.eu-west-1.compute.internal
Subject: Cron <ubuntu@ip-10-59-10-232> php -f /var/www/site2/modules/cron/cron_$
Content-Type: text/plain; charset=ANSI_X3.4-1968
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/ubuntu>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=ubuntu>
PHP Warning:  Memcache::getextendedstats(): No servers added to memcache connec$
PHP Warning:  Invalid argument supplied for foreach() in /var/www/site2/classes$
PHP Notice:  Undefined index: QUERY_STRING in /var/www/site2/classes/shop/Shop.$

 

Proof that the cron is working...

Proof that it seems to be tight to a memcache problem on the server OR prestashop 1.5 not to be compatible with crontab...

 

Any idea how to solve it?

 

Thanks,

Edited by TourisT (see edit history)
Link to comment
Share on other sites

No ideas?

 

Trying to solve the problem, I managed to make my Ubuntu use cron for the communication with Amazon Web Services. So it is working :)

 

But when I'm trying to call the prestashop 1.5 crontab addon, I get all the time:

PHP Notice: Undefined index: QUERY_STRING in /var/www/site2/classes/shop/

Shop.php on line 347

 

The truth is that I really have no clue where QUERY_STRING comes from...

 

Any idea how to sort it out?

 

Thanks,

Link to comment
Share on other sites

Yes, in 1.5.0.13, I can also find on line 347:

 

$url = 'http://'.$default_shop->domain.$default_shop->getBaseURI().'index.php?'.$_SERVER['QUERY_STRING'];

 

Any idea what QUERY_STRING stands for? How to bypass it?

 

Thanks,

Link to comment
Share on other sites

Thanks, then in the cron module, they say:

 

"Server crontab" is the best method but only if your server uses Linux and you have access to crontab. In that case add the line below to your crontab file.

* * * * * php -f /var/www/site2/modules/cron/cron_crontab.php

 

This triggers the error:

PHP Notice: Undefined index: QUERY_STRING in /var/www/site2/classes/shop/

 

We could think about:

* * * * * php -f /var/www/site2/modules/cron/cron_crontab.php?test=1

 

But it also fails:

Could not open input file: /var/www/site2/modules/cron/cron_crontab.php?test=1

 

Any solution for this?

Link to comment
Share on other sites

I changed

 

$url = 'http://'.$default_shop->domain.$default_shop->getBaseURI().'index.php?'.$_SERVER['QUERY_STRING'];

 

for

 

$url = isset('QUERY_STRING') ? 'http://'.$default_shop->domain.$default_shop->getBaseURI().'index.php?'.$_SERVER['QUERY_STRING'] : 'http://'.$default_shop->domain.$default_shop->getBaseURI().'index.php?';

 

is throwing back error:

PHP Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /var/www/site2/classes/shop/

Shop.php on line 347

 

Did I miss something?

Link to comment
Share on other sites

why try to execute with php ?

does the php file work if you access it completly under a browser in http://etc/cron.php

if yes? do just exaclty that with crontab

wget -somequite supressoptions- http://fullurl

 

php executable doesn't listen to .htaccess for instance ...

he probably also have a different php.ini ...

I even think that php executable doesnt have access to QUERY_STRING because it isn't a query string.

What you have is some weird path to a file that apparently gets accepted.

 

I think you should even have the arguments seperated by spaces.

thats how it is done on commandline ...

php -f /fullpath  arg1=1 arg2=34 arg3=56

Edited by AswinC (see edit history)
Link to comment
Share on other sites

  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...