Nahbyr
Nahbyr

Reputation: 510

Cron PHP simplexml error

I have written something that will import an external XML file. Everything works (fetching, reading, processing and saving) when executed from the browser.

However, it's not intended to be run manually every hour from the browser, so I need to set a cronjob for this:

enter image description here

I don't get anything from the file. When I put in:

libxml_use_internal_errors( true );
$xml = simplexml_load_file(<external-URL>); 

if (!$xml) {
  $errors = libxml_get_errors();

  foreach ($errors as $error) {
    print_r( $error );
  }
  libxml_clear_errors();
}

This is the output from CRON:

LibXMLError Object
(
    [level] => 1
    [code] => 1549
    [column] => 0
    [message] => failed to load external entity ""

    [file] =>
    [line] => 0
)

I've asked our hosting partner and they said 'allow_url_fopen' is turned on on every instance where it could matter.

I've searched all over the internet and I'm at a loss now.

I'm not that familiar with CRON, so help would be greatly appreciated.

Nahbyr

Upvotes: 0

Views: 535

Answers (1)

Webeng
Webeng

Reputation: 7123

Instead of this path you have:

/usr/bin/php -q /home/******/public_html/******/test2.php

Try using this path:

php /home/******/public_html/******/test2.php

Let me know if it works now!

Upvotes: 1

Related Questions