Googlemaps geocoding cron marked as executed but doesnt geocode anything

Hey there,

So here is my issue : I’ve planned the CRON to run every hour, in the job_qeue table it say everytime “success”, I’ve checked the link in the cron and he is ok (with https://).

But it doesnt geocode anything :

Stay on 0.0000

If I launch the geocode function from the link in the admin/Google Maps Geocode Count:
xxx.xx/index.php?module=jjwg_Maps&entryPoint=jjwg_Maps&cron=1

It work great. The issue cant be the address cause If I fire the link (so geocode it manually) it work great.

Also tryed to enable the logic hook in Google Maps Settings (I think its the before save hook), it change nothing. The issue is that a lot of my user user the map thing, but I cant just launch it manually everytime…

How can I fixes this ?

The difference might be that the browser will go through the web server PHP, while cron will use the CLI PHP. These will use different php.ini files for their settings, so there might be some difference there.

To find out your CLI PHP config file use

php -i | grep php.ini

Thanks for you reply @pgr,

Inside my SuiteCRM folder, with your command I found the php.ini, its the one at the root of my SuiteCRM folder, the config seems ok… :

allow_url_fopen = On;
memory_limit = 2048M;
max_execution_time = 50000;
max_input_time = -1;
upload_max_filesize = 64M;
post_max_size = 64M;
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE;
log_errors = On;
display_errors = Off;
error_log = /php-errors.log;
date.timezone = Europe/Paris;

Its the one I use in browser version too.

Here is what the cron look like in my crontab :
image

But for me he is actually working.

EDIT :
I saw some post that mention to edit the cron and specify the full php path. (I use only “php7.1” and it seems to work)

But with the command whereis php I found out thoses “7.3-cli”
image

Should I change my cron wit thoses “cli” version or its useless ?

Is cron.php getting executed or not? If it is, then you don’t need to mess with cron entries anymore.

In Admin / Schedulers, you can go into individual jobs and check their Last ran succesfully time (make sure it appears to be in the correct timezone, also).

Is any job running? Then your cron.php is executing.

Is the Geocoding job running? Then does it have any error in the logs?

Yep its executed (geocode CRON) :

As it is 10h33 here in France I assume its the correct timezone. The bad thing is that to test I’ve put another link and its marked as failed (just to test), If I reput the correct link its marked as success but it fail to cuz the geocode is not updated…

I dont have any error/fatal in my log :slightly_frowning_face:

Can you please check where I said - Admin /Schedulers, and not in Job queue?

Thats in the admin / Schedulers page, I have just took a screenshot of the subpanel, but here is the full page :

:thinking:

If you can’t understand what’s going wrong, you need to dig a little deeper. Maybe increase log level to DEBUG, see what it does during the job execution, and you can even compare the logs from when it runs successfully to the logs when it doesn’t work.

You can also add logging messages to the code, or (best option) run a debugging session on that code.

1 Like

I will do it when I will fix this problem, got some other before on my list. Will update this topic if I found any solution !

1 Like

@pgr,

After checking in the database, I can see that the registered datetime of the CRON is wrong by -1h .

on the 07/01/2020 at 15h in job_queue table, execute_time I have this :
2020-01-07 14:00:00

so its minus 1hour, maybe it can come from here.

In the user time zone everyone is on Europe/Paris (GMT +1:00)
php ini data : date.timezone = Europe/Paris;
In SSH if I type date I have the correct date time too :thinking:

If you type

php -i | grep timezone

do you get the same result as looking in

Admin / Diagnostics / phpinfo

:question:

The phpinfo from the diagnotics is correct (got paris too)

But the request grep/display nothing in SSH in the suitecrm folder.

Are you sure?

php -i doesn’t work?

Is your php in the PATH?

The php.ini file is in the root folder of my suitecrm instance

PHP -i display a raw html code,

If I c/c it in a html file and open it I can read " PHP Version 4.4.9"

Damn I cant understand how this work ahah

But if a search for timzone in this file, cant find nothing.

All my website are actually in php 7.3

EDIT : I have specified in all my cron the php version to run with, and its 7.1

The problem is that your web server PHP set up is ok, but your command-line PHP (CLI) isn’t. And this is what is used for the Scheduler Jobs, including the Geocoding one.

This should tell you which PHP it’s executing from command line:

which php

And then you can also know which php.ini that executable is using (you can define a timezone there, although I think first you should point this to a newer executable):

php -i | grep php.ini

You can search for ALL PHP executables in your system:

sudo find / -name php 2>/dev/null

Then it’s a matter of picking the right one, and making sure your PATH points to it first.

I am getting somewhere…

I my crontab I have specified the php version :

          • php7.1 /xxxxx/xx/xxxxx/xxxxxxxxxx/SuiteCRM/cron.php > /dev/null 2>&1

Now I am commenting on every update line 50 to 53 in cron.php :

$sapi_type = php_sapi_name();
if (substr($sapi_type, 0, 3) != ‘cli’) {
sugar_die(“cron.php is CLI only.”);
}

If I don’t comment them CRON is not running. (Got the info from here : cron help! (1and1 shared server))

I think it’s because I should use the -cli version of my host. like this :

          • /usr/bin/php7.3-cli /xxxxx/xx/xxxxx/xxxxxxxxxx/SuiteCRM/cron.php > /dev/null 2>&1

As a complete beginner I was thinking just specify the php version before was ok, didn’t know about CLI version.

EDIT :
just saw your answer from here : Need to solve SMTP problem with 1and1

you asked him to use this cron :

          • cd /path/to/suitecrm/folder/; usr/bin/php7.1-cli -d date.timezone=“America/New_York” -f /path/to/root/folder/cron.php > /dev/null 2>&1

I am also on a 1&1 shared hosting so maybe I should use this one too ?

Just add those elements if they are needed.

  • The path was added because otherwise it couldn’t find the PHP executable, or wasn’t using the correct one;

  • the timezone setting was added as a parameter because there was no way to edit a php.ini

1 Like

Okay so I’ve tried with :

/usr/bin/php7.3-cli /xxxxx/xx/xxxxx/xxxxxxxxxx/SuiteCRM/cron.php > /dev/null 2>&1

It changed nothing it execute the cron with 7.3-cli and put the geocode cron on success in job_queue. Same minus 1 hour on the execute time. Geocode still not doing hes job.

I can see that it use the good php.ini in the diag of the CRM. And so, the good timezone in it.

I will try to put the log on default during 24h …

Edit :
Do you think I have to try something like this ?
cd /xxxxxxxx/xxxxx/xxxxx/xxx/SuiteCRM; php -f cron.php > /dev/null 2>&1

Or maybe I have to specify the php version like this:
cd /xxxxxxxx/xxxxx/xxxxx/xxx/SuiteCRM; php7.3-cli -f cron.php > /dev/null 2>&1

Do you know how to fix that ?


The log time is good 15h26, but the log time is 14h26… Dont think the issue come frome here but I will test everything to make it work.

While debugging I found this ->

Thu Jan 9 16:00:02 2020 [12344][1][DEBUG] ----->SchedulersJob firing URL job: https://xxxxxxxxxxxxxx/index.php?module=jjwg_Maps&entryPoint=jjwg_Maps&cron=1

my cron is saved like this in the scheduler ->
https://xxxxxxxxxxxxxx/index.php?module=jjwg_Maps&entryPoint=jjwg_Maps&cron=1

ofc after I have this ->

Thu Jan 9 16:00:02 2020 [12344][1][DEBUG] ----->Firing was successful: https://xxxxxxxxxxxxxx/index.php?module=jjwg_Maps&entryPoint=jjwg_Maps&cron=1
Thu Jan 9 16:00:02 2020 [12344][1][DEBUG] ----->WTIH RESULT: HTTP/1.1 301 Moved Permanently

So its an encode issue of the URL … He is trying to access to a URL that doesnt exist…

But why he mark it as success in the job_queue so ?

Thu Jan 9 16:00:02 2020 [12344][1][INFO] Resolving job 9a8af89d-8030-638e-a62a-5e173f70ce54 as success:
Thu Jan 9 16:00:02 2020 [12344][1][DEBUG] Hook called: SchedulersJobs::before_save
Thu Jan 9 16:00:02 2020 [12344][1][INFO] Query:UPDATE job_queue
SET assigned_user_id=‘1’,name=‘Google Maps Geocoding Process’,date_modified=‘2020-01-09 15:00:01’,scheduler_id=‘648ef1e9-704f-96c9-e789-5d02083b48e2’,execute_time=‘2020-01-09 15:00:00’,status=‘done’,resolution=‘success’,message=NULL,target=‘url::https://xxxxxxxxxxxxxx/index.php?module=jjwg_Maps&entryPoint=jjwg_Maps&cron=1’,data=NULL,requeue=0,retry_count=NULL,failure_count=NULL,job_delay=0,client=‘CRONa0af2a63b6342f94d4a6e68c780ac405:12344’,percent_complete=NULL
WHERE job_queue.id = ‘9a8af89d-8030-638e-a62a-5e173f70ce54’ AND deleted=0

It just accepts any HTTP code below 400 from the server as a response. Only when the call fails to actually execute at all, does it return an error.

You just try to find out why it’s giving you a 301. Check your web server and your htaccess

Maybe for the 301 redirects, it needs to have extra code to get the redirected URL and fire a second request. Bu that code is not there yet.

1 Like