<?xml version="1.0"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Transition Technology: Ticket #768: Piwik Archive Cron Error</title>
    <link>http://localhost:8080/trac/ticket/768</link>
    <description>&lt;p&gt;
Have been getting these emails from &lt;a class="wiki" href="http://localhost:8080/trac/wiki/PiwikServer"&gt;PiwikServer&lt;/a&gt;:
&lt;/p&gt;
&lt;pre class="wiki"&gt;From: root@penguin.webarch.net (Cron Daemon)
Date: Fri,  1 Aug 2014 14:06:48 +0100 (BST)
To: root@localhost
Subject: Cron &amp;lt;www-data@penguin&amp;gt; /web/stats.transitionnetwork.org/piwik/console core:archive --url=http://stats.transitionnetwork.org/ &amp;gt; /var/log/piwik-archive.log
ERROR CoreConsole[2014-08-01 13:05:18] [3e5ac] Got invalid response from API request:
+http://stats.transitionnetwork.org/index.php?module=API&amp;amp;method=API.get&amp;amp;idSite=1&amp;amp;period=week&amp;amp;date=last2&amp;amp;format=php&amp;amp;token_auth=XXXXXXXXXXXX&amp;amp;trigger=archivephp. Response was ' &amp;lt;div style='word-wrap: break-word; border: 3px solid red; padding:4px; width:70%;
+background-color:#FFFF96;'&amp;gt;         &amp;lt;strong&amp;gt;There is an error. Please report the message (Piwik 2.4.1)         and full backtrace in the &amp;lt;a
+href='?module=Proxy&amp;amp;action=redirect&amp;amp;url=http://forum.piwik.org' target='_blank'&amp;gt;Piwik forums&amp;lt;/a&amp;gt; (please do a Search first as it might have
+been reported already!).&amp;lt;br /&amp;gt;&amp;lt;br/&amp;gt;         Warning:&amp;lt;/strong&amp;gt;
+&amp;lt;em&amp;gt;file_get_contents(http://api.piwik.org/1.0/getLatestVersion/?piwik_version=2.4.1&amp;amp;php_version=5.4.4-14%2Bdeb7u12&amp;amp;url=https%3A%2F%2Fstats.
+transitionnetwork.org%2Fweb%2Fstats.transitionnetwork.org%2Fpiwik%2Fconsole&amp;amp;trigger=API&amp;amp;timezone=Europe%2FLondon): failed to open stream:
+HTTP requ
 est fail
 ed! &amp;lt;/em&amp;gt; in &amp;lt;strong&amp;gt;/web/stats.transitionnetwork.org/piwik/core/Http.php&amp;lt;/strong&amp;gt; on line &amp;lt;strong&amp;gt;406&amp;lt;/strong&amp;gt; &amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;Backtrace
+--&amp;amp;gt;&amp;lt;div style="font-family:Courier;font-size:10pt"&amp;gt;&amp;lt;br /&amp;gt; #0  Piwik\Error::errorHandler(...) called at [:]&amp;lt;br /&amp;gt; #1
+file_get_contents(...) called at [/web/stats.transitionnetwork.org/piwik/core/Http.php:406]&amp;lt;br /&amp;gt; #2  Piwik\Http::sendHttpRequestBy(...)
+called at [/web/stats.transitionnetwork.org/piwik/core/Http.php:94]&amp;lt;br /&amp;gt; #3  Piwik\Http::sendHttpRequest(...) called at
+[/web/stats.transitionnetwork.org/piwik/core/UpdateCheck.php:72]&amp;lt;br /&amp;gt; #4  Piwik\UpdateCheck::check(...) called at
+[/web/stats.transitionnetwork.org/piwik/plugins/CoreUpdater/CoreUpdater.php:142]&amp;lt;br /&amp;gt; #5
+Piwik\Plugins\CoreUpdater\CoreUpdater-&amp;gt;updateCheck(...) called at [:]&amp;lt;br /&amp;gt; #6  call_user_func_array(...) called at
+[/web/stats.transitionnetwork.org/piwik/core/EventDispatcher.php:98]&amp;lt;br /&amp;gt; #7  Piwik\EventDispatcher-&amp;gt;postEvent(...) called at
+[/web/stats.transitionnetwor
 k.org/pi
 wik/core/Piwik.php:766]&amp;lt;br /&amp;gt; #8  Piwik\Piwik::postEvent(...) called at
+[/web/stats.transitionnetwork.org/piwik/core/FrontController.php:391]&amp;lt;br /&amp;gt; #9  Piwik\FrontController-&amp;gt;init(...) called at
+[/web/stats.transitionnetwork.org/piwik/core/dispatch.php:33]&amp;lt;br /&amp;gt; #10  require_once(...) called at
+[/web/stats.transitionnetwork.org/piwik/index.php:47]&amp;lt;br /&amp;gt; #11  require_once(...) called at
+[/web/stats.transitionnetwork.org/piwik/core/CliMulti/RequestCommand.php:53]&amp;lt;br /&amp;gt; #12  Piwik\CliMulti\RequestCommand-&amp;gt;execute(...) called
+at [/web/stats.transitionnetwork.org/piwik/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:252]&amp;lt;br /&amp;gt; #13
+Symfony\Component\Console\Command\Command-&amp;gt;run(...) called at
+[/web/stats.transitionnetwork.org/piwik/vendor/symfony/console/Symfony/Component/Console/Application.php:887]&amp;lt;br /&amp;gt; #14
+Symfony\Component\Console\Application-&amp;gt;doRunCommand(...) called at
+[/web/stats.transitionnetwork.org/piwik/vendor/symfony/console/Symfony/Component/Co
 nsole/Ap
 plication.php:193]&amp;lt;br /&amp;gt; #15  Symfony\Component\Console\Application-&amp;gt;doRun(...) called at
+[/web/stats.transitionnetwork.org/piwik/core/Console.php:64]&amp;lt;br /&amp;gt; #16  Piwik\Console-&amp;gt;doRun(...) called at
+[/web/stats.transitionnetwork.org/piwik/vendor/symfony/console/Symfony/Component/Console/Application.php:124]&amp;lt;br /&amp;gt; #17
+Symfony\Component\Console\Application-&amp;gt;run(...) called at [/web/stats.transitionnetwork.org/piwik/console:31]&amp;lt;br /&amp;gt; &amp;lt;/div&amp;gt;&amp;lt;br /&amp;gt;
+&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;br /&amp;gt;  &amp;lt;div style='word-wrap: break-word; border: 3px solid red; padding:4px; width:70%; background-color:#FFFF96;'&amp;gt;
+&amp;lt;strong&amp;gt;There is an error. Please report the message (Piwik 2.4.1)         and full backtrace in the &amp;lt;a
+href='?module=Proxy&amp;amp;action=redirect&amp;amp;url=http://forum.piwik.org' target='_blank'&amp;gt;Piwik forums&amp;lt;/a&amp;gt; (please do a Search first as it might have
+been reported already!).&amp;lt;br /&amp;gt;&amp;lt;br/&amp;gt;         Warning:&amp;lt;/strong&amp;gt;
+&amp;lt;em&amp;gt;file_get_contents(http://api.piwik.org/1.0/getLatestVersion/?piwik_version=2.4.1&amp;amp;php_version
 =5.4.4-1
&lt;/pre&gt;</description>
    <language>en-us</language>
    <image>
      <title>Transition Technology</title>
      <url>/trac/chrome/site/TransitionNetwork-Logo-Web-Small.jpg</url>
      <link>http://localhost:8080/trac/ticket/768</link>
    </image>
    <generator>Trac 0.12.5</generator>
    <item>
      
        <dc:creator>chris</dc:creator>

      <pubDate>Fri, 01 Aug 2014 17:37:22 GMT</pubDate>
      <title>hours, totalhours changed</title>
      <link>http://localhost:8080/trac/ticket/768#comment:1</link>
      <guid isPermaLink="false">http://localhost:8080/trac/ticket/768#comment:1</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;hours&lt;/strong&gt;
                changed from &lt;em&gt;0.0&lt;/em&gt; to &lt;em&gt;0.35&lt;/em&gt;
            &lt;/li&gt;
            &lt;li&gt;&lt;strong&gt;totalhours&lt;/strong&gt;
                changed from &lt;em&gt;0.0&lt;/em&gt; to &lt;em&gt;0.35&lt;/em&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
        &lt;p&gt;
The &lt;a class="wiki" href="http://localhost:8080/trac/wiki/PiwikServer"&gt;PiwikServer&lt;/a&gt; crontab, which was run as user &lt;tt&gt;www-data&lt;/tt&gt; was commented out a while ago:
&lt;/p&gt;
&lt;pre class="wiki"&gt;# http://piwik.org/docs/setup-auto-archiving/
#5 * * * * /web/stats.transitionnetwork.org/piwik/misc/cron/archive.sh &amp;gt; /dev/null
&lt;/pre&gt;&lt;p&gt;
And now we have &lt;tt&gt;/etc/cron.d/piwik-archive&lt;/tt&gt; which contains:
&lt;/p&gt;
&lt;pre class="wiki"&gt;MAILTO="root@localhost"
5 * * * * www-data /web/stats.transitionnetwork.org/piwik/console core:archive --url=http://stats.transitionnetwork.org/ &amp;gt; /var/log/piwik-archive.log
&lt;/pre&gt;&lt;p&gt;
The documentation for this is:
&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;a class="ext-link" href="http://piwik.org/docs/setup-auto-archiving/#linuxunix-how-to-set-up-a-crontab-to-automatically-archive-the-reports"&gt;&lt;span class="icon"&gt;​&lt;/span&gt;http://piwik.org/docs/setup-auto-archiving/#linuxunix-how-to-set-up-a-crontab-to-automatically-archive-the-reports&lt;/a&gt;
&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;
I have spent some time searching for any reported bugs regarding this issue, it appears to be intermittent. Haven't found an answer yet.
&lt;/p&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>chris</dc:creator>

      <pubDate>Fri, 01 Aug 2014 17:37:46 GMT</pubDate>
      <title>description changed</title>
      <link>http://localhost:8080/trac/ticket/768#comment:2</link>
      <guid isPermaLink="false">http://localhost:8080/trac/ticket/768#comment:2</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;description&lt;/strong&gt;
              modified (&lt;a href="/trac/ticket/768?action=diff&amp;amp;version=2"&gt;diff&lt;/a&gt;)
            &lt;/li&gt;
          &lt;/ul&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>chris</dc:creator>

      <pubDate>Fri, 01 Aug 2014 18:13:53 GMT</pubDate>
      <title></title>
      <link>http://localhost:8080/trac/ticket/768#comment:3</link>
      <guid isPermaLink="false">http://localhost:8080/trac/ticket/768#comment:3</guid>
      <description>
        &lt;p&gt;
The description of this ticket was edited to remove the token_auth string, I have since changed my password for Piwik and this has reset the token_auth, this can be checked at a MySQL level, eg:
&lt;/p&gt;
&lt;pre class="wiki"&gt;select login from user where token_auth="XXXX";
&lt;/pre&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>chris</dc:creator>

      <pubDate>Wed, 03 Sep 2014 10:58:54 GMT</pubDate>
      <title>hours, totalhours changed</title>
      <link>http://localhost:8080/trac/ticket/768#comment:4</link>
      <guid isPermaLink="false">http://localhost:8080/trac/ticket/768#comment:4</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;hours&lt;/strong&gt;
                changed from &lt;em&gt;0.0&lt;/em&gt; to &lt;em&gt;0.25&lt;/em&gt;
            &lt;/li&gt;
            &lt;li&gt;&lt;strong&gt;totalhours&lt;/strong&gt;
                changed from &lt;em&gt;0.35&lt;/em&gt; to &lt;em&gt;0.6&lt;/em&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
        &lt;p&gt;
Replying to &lt;a href="http://localhost:8080/trac/ticket/768#comment:1" title="Comment 1 for Ticket #768"&gt;chris&lt;/a&gt;:
&lt;/p&gt;
&lt;blockquote class="citation"&gt;
&lt;p&gt;
And now we have &lt;tt&gt;/etc/cron.d/piwik-archive&lt;/tt&gt; which contains:
&lt;/p&gt;
&lt;pre class="wiki"&gt;MAILTO="root@localhost"
5 * * * * www-data /web/stats.transitionnetwork.org/piwik/console core:archive --url=http://stats.transitionnetwork.org/ &amp;gt; /var/log/piwik-archive.log
&lt;/pre&gt;&lt;/blockquote&gt;
&lt;p&gt;
I have changed that to:
&lt;/p&gt;
&lt;pre class="wiki"&gt;MAILTO="root@localhost"
5 * * * * www-data /web/stats.transitionnetwork.org/piwik/console core:archive --url=http://stats.transitionnetwork.org/ &amp;gt;&amp;gt; /var/log/piwik-archive.log
&lt;/pre&gt;&lt;p&gt;
So logs are appended rather than clobbered and also added log rotation by creating &lt;tt&gt;/etc/logrotate.d/piwik&lt;/tt&gt; which contains:
&lt;/p&gt;
&lt;pre class="wiki"&gt;/var/log/piwik-archive.log {
        daily
        missingok
        rotate 30
        compress
        delaycompress
        notifempty
}
&lt;/pre&gt;&lt;blockquote class="citation"&gt;
&lt;p&gt;
I have spent some time searching for any reported bugs regarding this issue, it appears to be intermittent. Haven't found an answer yet.
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
Recent emails have this error:
&lt;/p&gt;
&lt;pre class="wiki"&gt;From: root@penguin.webarch.net (Cron Daemon)
Date: Thu, 28 Aug 2014 01:13:07 +0100 (BST)
To: root@localhost
Subject: Cron &amp;lt;www-data@penguin&amp;gt; /web/stats.transitionnetwork.org/piwik/console core:archive --url=http://stats.transitionnetwork.org/ &amp;gt; /var/log/piwik-archive.log
ERROR CoreConsole[2014-08-28 00:10:38] [69fb6] Got invalid response from API request: http://stats.transitionnetwork.org/index.php?module=API&amp;amp;method=API.get&amp;amp;idSite=1&amp;amp;period=day&amp;amp;date=last2&amp;amp;format=php&amp;amp;token_auth=XXXX&amp;amp;trigger=archivephp. The response was empty. This usually means a server error. This solution to this error is generally to increase the value of 'memory_limit' in your php.ini file. Please check your Web server Error Log file for more details.
ERROR CoreConsole[2014-08-28 00:10:38] [69fb6] Empty or invalid response '' for website id 1, Time elapsed: 7.769s, skipping
ERROR CoreConsole[2014-08-28 00:10:53] [69fb6] Got invalid response from API request: http://stats.transitionnetwork.org/index.php?module=API&amp;amp;method=API.get&amp;amp;idSite=7&amp;amp;period=day&amp;amp;date=last2&amp;amp;format=php&amp;amp;token_auth=XXXX&amp;amp;trigger=archivephp. The response was empty. This usually means a server error. This solution to this error is generally to increase the value of 'memory_limit' in your php.ini file. Please check your Web server Error Log file for more details.
ERROR CoreConsole[2014-08-28 00:10:53] [69fb6] Empty or invalid response '' for website id 7, Time elapsed: 15.540s, skipping
ERROR CoreConsole[2014-08-28 00:13:07] [69fb6] 4 total errors during this script execution, please investigate and try and fix these errors.
&lt;/pre&gt;&lt;p&gt;
So I have doubled the &lt;tt&gt;memory_limit&lt;/tt&gt; in &lt;tt&gt;/etc/php5/fpm/php.ini&lt;/tt&gt;:
&lt;/p&gt;
&lt;pre class="wiki"&gt;;memory_limit = 128M
memory_limit = 256M
&lt;/pre&gt;&lt;p&gt;
And in restarted php5-fpm.
&lt;/p&gt;
&lt;p&gt;
This might have fixed it, will check tomorrow.
&lt;/p&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>chris</dc:creator>

      <pubDate>Thu, 04 Sep 2014 09:19:07 GMT</pubDate>
      <title>hours, totalhours changed</title>
      <link>http://localhost:8080/trac/ticket/768#comment:5</link>
      <guid isPermaLink="false">http://localhost:8080/trac/ticket/768#comment:5</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;hours&lt;/strong&gt;
                changed from &lt;em&gt;0.0&lt;/em&gt; to &lt;em&gt;0.1&lt;/em&gt;
            &lt;/li&gt;
            &lt;li&gt;&lt;strong&gt;totalhours&lt;/strong&gt;
                changed from &lt;em&gt;0.6&lt;/em&gt; to &lt;em&gt;0.7&lt;/em&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
        &lt;p&gt;
No errors since the changes yesterday, but we now have logs to used to check if there have been errors.
&lt;/p&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>chris</dc:creator>

      <pubDate>Fri, 05 Sep 2014 09:47:18 GMT</pubDate>
      <title>hours, totalhours changed</title>
      <link>http://localhost:8080/trac/ticket/768#comment:6</link>
      <guid isPermaLink="false">http://localhost:8080/trac/ticket/768#comment:6</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;hours&lt;/strong&gt;
                changed from &lt;em&gt;0.0&lt;/em&gt; to &lt;em&gt;0.3&lt;/em&gt;
            &lt;/li&gt;
            &lt;li&gt;&lt;strong&gt;totalhours&lt;/strong&gt;
                changed from &lt;em&gt;0.7&lt;/em&gt; to &lt;em&gt;1.0&lt;/em&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
        &lt;p&gt;
There was another error last night:
&lt;/p&gt;
&lt;pre class="wiki"&gt;Date: Fri,  5 Sep 2014 01:11:30 +0100 (BST)
To: root@localhost
Subject: Cron &amp;lt;www-data@penguin&amp;gt; /web/stats.transitionnetwork.org/piwik/console core:archive --url=http://stats.transitionnetwork.org/ &amp;gt;&amp;gt; /var/log/piwik-archive.log
ERROR CoreConsole[2014-09-05 00:08:46] [65cbf] Got invalid response from API request: http://stats.transitionnetwork.org/index.php?module=API&amp;amp;method=API.get&amp;amp;idSite=1&amp;amp;period=day&amp;amp;date=last2&amp;amp;format=php&amp;amp;token_auth=XXXX&amp;amp;trigger=archivephp. The response was empty. This usually means a server error. This solution to this error is generally to increase the value of 'memory_limit' in your php.ini file. Please check your Web server Error Log file for more details.
ERROR CoreConsole[2014-09-05 00:08:46] [65cbf] Empty or invalid response '' for website id 1, Time elapsed: 8.091s, skipping
ERROR CoreConsole[2014-09-05 00:11:30] [65cbf] 2 total errors during this script execution, please investigate and try and fix these errors.
&lt;/pre&gt;&lt;p&gt;
The above error in the logs:
&lt;/p&gt;
&lt;pre class="wiki"&gt;ERROR CoreConsole[2014-09-05 00:08:46] [65cbf] Got invalid response from API request: http://stats.transitionnetwork.org/index.php?module=API&amp;amp;method=API.get&amp;amp;idSite=1&amp;amp;period=day&amp;amp;date=last2&amp;amp;format=php&amp;amp;token_auth=XXXX&amp;amp;trigger=archivephp. The response was empty. This usually means a server error. This solution to this error is generally to increase the value of 'memory_limit' in your php.ini file. Please check your Web server Error Log file for more details.
INFO CoreConsole[2014-09-05 00:11:30] [65cbf] Error: Got invalid response from API request: http://stats.transitionnetwork.org/index.php?module=API&amp;amp;method=API.get&amp;amp;idSite=1&amp;amp;period=day&amp;amp;date=last2&amp;amp;format=php&amp;amp;token_auth=XXXX&amp;amp;trigger=archivephp. The response was empty. This usually means a server error. This solution to this error is generally to increase the value of 'memory_limit' in your php.ini file. Please check your Web server Error Log file for more details.
INFO CoreConsole[2014-09-05 00:11:30] [65cbf] Error: Empty or invalid response '' for website id 1, Time elapsed: 8.091s, skipping
&lt;/pre&gt;&lt;p&gt;
It's worth nothing that most of these errors have been around 1:10am BST (00:10 UTC, the server is on UTC), perhaps this is the same time that the backups are being generated and and answer is to amend the crontab so it doesn't run at this time.
&lt;/p&gt;
&lt;p&gt;
So following &lt;a class="ext-link" href="https://stackoverflow.com/questions/8764150/crontab-run-every-15-minutes-except-at-3am"&gt;&lt;span class="icon"&gt;​&lt;/span&gt;the suggestion here&lt;/a&gt; I have edited &lt;tt&gt;/etc/cron.d/piwik-archive&lt;/tt&gt; so it won't run at midnight or 1am:
&lt;/p&gt;
&lt;pre class="wiki"&gt;MAILTO="root@localhost"
#5 * * * * www-data /web/stats.transitionnetwork.org/piwik/console core:archive --url=http://stats.transitionnetwork.org/ &amp;gt;&amp;gt; /var/log/piwik-archive.log
5 2-23 * * * www-data /web/stats.transitionnetwork.org/piwik/console core:archive --url=http://stats.transitionnetwork.org/ &amp;gt;&amp;gt; /var/log/piwik-archive.log
&lt;/pre&gt;&lt;p&gt;
Hopefully that will solve this issue.
&lt;/p&gt;
      </description>
      <category>Ticket</category>
    </item>
 </channel>
</rss>