Cron error [solved]

Look here if you're having trouble with BitShop
User avatar
krang
Posts: 28
Joined: Mon Dec 14, 2015 10:27 am
Location: Dimension X
Contact:

Cron error [solved]

Post by krang »

Hi,

I setup my cron for root user like this:

Code: Select all

0 */4 * * * /usr/bin/php -q /var/www/blahblahblah/cron/tick_update.php > /dev/null
it looks to work fine but it shows error:

Code: Select all

PHP Notice:  Undefined index: HTTP_HOST in /var/www/blahblahblah/inc/config.inc.php on line 89
ekhm I know I can use

Code: Select all

/dev/null 2>&1
and I will don't get any email notifications but I would like to know is this some issue and how to solve error message?

Also why do I need add -q parameter, it's in BitShop setup instruction.

Thanks
User avatar
bitfreak
Site Admin
Posts: 98
Joined: Thu Dec 10, 2015 6:57 pm
Location: Australia
Contact:

Re: Cron error

Post by bitfreak »

That error probably means you're running on a server without a host name. Replace the $_SERVER['HTTP_HOST'] variable with the server IP and it should work. And I think the -q parameter means quiet mode, should stop the email notifications or something like that.
johnny508
Posts: 2
Joined: Mon Mar 14, 2016 10:42 am

Re: Cron error [solved]

Post by johnny508 »

Can u guys help me understand something.. I always struggle keeping crinjobs for bitcoin apis working properly.

I know how to run a cron job with command similar to one above.

And i can see it running and it looks like the place its reaching out to successfully connected, etc.

But i struggle to understand how to check if the returned data is coming back and going into the proper places on my webshop.

Is there some command switch that would allow me to see what is being returned and where it going?

Are there switches that u guys would recommend researching as the most commonly used switches!
User avatar
bitfreak
Site Admin
Posts: 98
Joined: Thu Dec 10, 2015 6:57 pm
Location: Australia
Contact:

Re: Cron error [solved]

Post by bitfreak »

@johnny508: take a look at the /cron/tick_update.php file, the data returned is saved to $json_result and then a quick check is done to make sure it returned valid data.
User avatar
krang
Posts: 28
Joined: Mon Dec 14, 2015 10:27 am
Location: Dimension X
Contact:

Re: Cron error

Post by krang »

bitfreak wrote:That error probably means you're running on a server without a host name. Replace the $_SERVER['HTTP_HOST'] variable with the server IP and it should work. And I think the -q parameter means quiet mode, should stop the email notifications or something like that.
I did this in line:
$http_host = empty($_SERVER['HTTP_HOST']) ? server_name() : $_SERVER['HTTP_HOST'];

and changed $_SERVER['HTTP_HOST'] for ip of my server here empty($_SERVER['HTTP_HOST']) and empty($_SERVER['HTTP_HOST'])
I am not sure it should be changed in both places but I tried only at the beginning then at the end and all 3 solutions doesn't work.

error:
PHP Parse error: syntax error, unexpected '.115' (T_DNUMBER) in /var/www/pawnshop/inc/config.inc.php on line 100

115 is part of my ip address
User avatar
krang
Posts: 28
Joined: Mon Dec 14, 2015 10:27 am
Location: Dimension X
Contact:

Re: Cron error [solved]

Post by krang »

I see on your main page of BitShop, Bitcoin rate is also out of date.

Maybe it is something about mod_rewrite rules? I am using Lighttpd server so maybe I need create some because Lighttpd using own syntax.
Anyway even if it is not about rewrite could you please create list of mod_rewrite rules for BitShop for Lighttpd?

Or how I can setup Http_Host? I know Server_Name can be added to webserver conf. But Http_host is something from Http request header.
User avatar
bitfreak
Site Admin
Posts: 98
Joined: Thu Dec 10, 2015 6:57 pm
Location: Australia
Contact:

Re: Cron error [solved]

Post by bitfreak »

error:
PHP Parse error: syntax error, unexpected '.115' (T_DNUMBER) in /var/www/pawnshop/inc/config.inc.php on line 100

115 is part of my ip address
The newest version of BitShop should have fixed this problem for you automatically, but to give you a solution for earlier versions, you probably need to put your IP address inside quotes.
I see on your main page of BitShop, Bitcoin rate is also out of date.
Thanks for pointing that out, seems there is some sort of issue with the cron job stuff, I'll look into it shortly.

EDIT: Ok it looks like the issue is a permission issue. It depends on your server settings, but usually cron jobs won't run the script as the apache user so it wont have permission to edit the weighted_prices.json file since the weighted_prices.json file is usually owned by the apache user. It could be quickly fixed by applying less restrictive permissions to the weighted_prices.json file but that may open up security holes. I'll see if I can come up with a better solution and include it in the next version of BitShop.
User avatar
krang
Posts: 28
Joined: Mon Dec 14, 2015 10:27 am
Location: Dimension X
Contact:

Re: Cron error [solved]

Post by krang »

I tried with quotes double " and single ' but still nothing. For temporary solution I just paste path to tick_update.php into browser and it works and update bitcoin status.
I would not like to add ip into any script file inside www folder because my shop is running as a hidden service in Tor.

Fingers crossed for any other solution :)
User avatar
bitfreak
Site Admin
Posts: 98
Joined: Thu Dec 10, 2015 6:57 pm
Location: Australia
Contact:

Re: Cron error [solved]

Post by bitfreak »

krang wrote:I tried with quotes double " and single ' but still nothing.
If you're using v1.1.1 then it should automatically work without having to add your IP address.
User avatar
krang
Posts: 28
Joined: Mon Dec 14, 2015 10:27 am
Location: Dimension X
Contact:

Re: Cron error [solved]

Post by krang »

Could you please give me an example on line below, how it should looks like? Would you be so nice and put any IP in line below to show me how it should be configured?

$http_host = empty($_SERVER['HTTP_HOST']) ? server_name() : $_SERVER['HTTP_HOST'];

Thanks in advanced!
Post Reply