Error when running import_logs.py as cronjob

Hi PIWIK,
we have an issue when running import_logs.py as cronjob.
line in shell script:
/var/www/html/piwik/misc/log-analytics/import_logs.py -d --login=root --password=hmbtghmbtg --url=http://localhost/piwik $logfile --idsite=1 --recorders=4 --enable-http-errors --enable-http-redirects --enable-static --enable-bots &>>$PIWIK_LOG

Error message from import-logs.py:
2014-11-10 16:58:02,396: [DEBUG] Accepted hostnames: all
2014-11-10 16:58:02,396: [DEBUG] Piwik URL is: http://localhost/piwik
2014-11-10 16:58:02,396: [DEBUG] No token-auth specified
2014-11-10 16:58:02,396: [DEBUG] Using credentials: (login = root, password = xxxxx)
2014-11-10 16:58:02,410: [DEBUG] Error when connecting to Piwik: HTTP Error 404: Not found
2014-11-10 16:58:04,422: [DEBUG] Error when connecting to Piwik: HTTP Error 404: Not found
2014-11-10 16:58:06,431: [DEBUG] Error when connecting to Piwik: HTTP Error 404: Not found
Fatal error: Not found

When running the same script from terminal it works fine.
Do you have any idea?
Kind regards
hullrich

try maybe URL to http://localhost/piwik/ ?

Hello Matt,
unfortunately changing command to:
/var/www/html/piwik/misc/log-analytics/import_logs.py -d --login=root --password=xxxxxxx --url=localhost/piwik/ /home/hmbtg-analyse/bin/testPiwik.log --idsite=1 --recorders=4 --enable-http-errors --enable-http-redirects --enable-static --enable-bots --dry-run &>>$PIWIK_LOG
does not help.
Output when starting from terminal or manually from crontab:
2014-11-13 10:17:23,367: [DEBUG] Accepted hostnames: all
2014-11-13 10:17:23,368: [DEBUG] Piwik URL is: http://localhost/piwik/
2014-11-13 10:17:23,368: [DEBUG] No token-auth specified
2014-11-13 10:17:23,368: [DEBUG] Using credentials: (login = root, password = c4401a93dc35098941975f65fa605e05)
2014-11-13 10:17:23,409: [DEBUG] Authentication token token_auth is: e788e3b6775b364941b593c5bb7fa3b4
2014-11-13 10:17:23,410: [DEBUG] Resolver: static
2014-11-13 10:17:23,461: [DEBUG] Launched recorder
2014-11-13 10:17:23,461: [DEBUG] Launched recorder
2014-11-13 10:17:23,462: [DEBUG] Launched recorder
2014-11-13 10:17:23,463: [DEBUG] Launched recorder

Output when starting automatically from crontab:
2014-11-13 10:11:07,109: [DEBUG] Accepted hostnames: all
2014-11-13 10:11:07,109: [DEBUG] Piwik URL is: http://localhost/piwik/
2014-11-13 10:11:07,109: [DEBUG] No token-auth specified
2014-11-13 10:11:07,109: [DEBUG] Using credentials: (login = root, password = c4401a93dc35098941975f65fa605e05)
2014-11-13 10:11:07,128: [DEBUG] Error when connecting to Piwik: HTTP Error 404: Not found
2014-11-13 10:11:09,563: [DEBUG] Error when connecting to Piwik: HTTP Error 404: Not found
2014-11-13 10:11:11,577: [DEBUG] Error when connecting to Piwik: HTTP Error 404: Not found
Fatal error: Not found

In both case URL is resolved to http://localhost/piwik/.
Do you have any other suggestions?
Cheers, Hartmut

Sorry I dont know what could cause this!

[size=x-small][/size]Hi Matt,
we are still working on this issue that the import script fails when started automatically from crontab.
When start from shell or manually from crontab via gnome scheduler everything works fine.
The debug log information we get now is:
[size=small][u]2014-11-27 15:38:02,718: [DEBUG] Accepted hostnames: all
2014-11-27 15:38:02,718: [DEBUG] Piwik URL is: http://localhost/piwik/
2014-11-27 15:38:02,718: [DEBUG] No token-auth specified
2014-11-27 15:38:02,718: [DEBUG] Using credentials: (login = xxxx, password = xxxxxxxxxxxxxxxxx)
2014-11-27 15:38:02,731: [DEBUG] Error when connecting to Piwik: <urlopen error Piwik returned an invalid response:

Firewall Authentication
Firewall Authentication

Firewall Authentication

You are requesting a restricted connection limited to authenticated users only. Enter your firewall login data and press Login to authenticate on the firewall.

Firewall Authentication failed

Login was not successful.
Restricted network connections are denied.

......... ......... ......... name="origin" value="Login"/>
[/u][/size]

Can you see any reason for this issue?
Cheers, Hartmut

Yes it looks like your firewall is catching the request, this should directly go to Piwik:

Firewall Authentication

mmh, the situation is that piwik and the import script are on the same server. So there should be no network access through firewalls.
On this server the firewall is inactive:
sudo ufw status
[sudo] password for hmbtg-analyse:
Status: inactive
What do you think?
Cheers, Hartmut