strange problem with webalizer and date

Discussion in 'Installation/Configuration' started by gilas, Jul 5, 2015.

  1. gilas

    gilas Member

    Hi Till
    first always my congratulation for your great work ab. ispconfig.
    Looking for my webalizer stats, I found that the files generated within stats folder are not for *yesterday* but for the day before.
    I.e. today is 5 July; this night cron ran cron_daily.php at 00:30; the stats generated are not for 4 July but for 3 July.
    Inspecting the php code I added a line to write the data in /var/log/messages using the PHP log function. I discovered that the data calculates is 3 July instead of 4 July.
    But this morning to check what time is now, I used:
    data (from linux shell) all is Ok: 10:30
    data -u
    this is not OK, because the clock is 8:30 (2 hours back).
    I suspect this is the problem:
    * cron_daily.php runs at 00:30
    * calculates 1 day before
    * ... but one day before is *not* yesterday but the day before
    so my stats are not updated correcly.
    Now I copied some lines for webalizer from your cron_daily.php to cron_daily_manual.php and run; reading stats the data are OK.
    What can I do to set the data correctly?!?
    note: I'm using;
    PHP 5.4.42 (cli) (built: Jun 10 2015 14:32:15)
    ISPConfig version is
    maybe I'm wrong but, waiting for an answer, I modified your cron_daily.php as follows:
    disabled line:
    //$yesterday = date('Ymd', strtotime("-1 day", time()));
    added line
    $yesterday = date('Ymd',time() - 7200);

    so that my time before today 00:30 should be surely 'yesterday'

    thank you for your help
  2. gilas

    gilas Member

    some other info:
    if I run PHP via CLI the date of the day before is calculated OK?
    it seems that this problem happens only when it is used CRON
    /etc/php.ini is set correctly
    with the timezone Rome/Europe

    this is the log line added at 00:30 to /var/log/messages:
    Jul 5 00:32:14 www php: [WEBALIZER_ISPCONFIG] /usr/bin/webalizer -c /var/www/clients/client32/web103/log/webalizer.conf -n -s -r -q -T -p -o /var/www/clients/client32/web103/web/stats /var/www/clients/client32/web103/log/20150703-access.log

    as you can see the date is Jul 5 00:32 and the stats are generated accessing to log file:

    ---> another test: the problems could be linked to your ISPConfig configuration? I discovered:

    lib/$conf['timezone'] = 'UTC';
    (obviously if the time forced for cron_daily.php is UTC this is not right....)
    on my VPS should be CEST
    Last edited: Jul 5, 2015
  3. till

    till Super Moderator Staff Member ISPConfig Developer

    This measn that thet the timezone that is set in ispconfig does not match with the timezone that is configured in /usr/local/ispconfig/server/
  4. gilas

    gilas Member

    thank you Till! I modified my cron_daily_manual.php to verify this and restored the previous string to the right time, calculated with PHP:

    $yesterday = date('Ymd', strtotime("-1 day", time()));

    this night all will be OK (I supposed). I'll checked for the stats tomorrow. Have a nice day!

Share This Page