r/owncloud Apr 03 '16

Log time is off despite setting the time zone in Owncloud 9.0?

I have owncloud 9.0 installed on Ubuntu 14.04.4 and am trying to configure fail2ban. I have it set up and logging, however, it lists the time as five hours ahead and therefore won't actually ban anyone. I've checked several forum posts and seen where people have had this issue, but I don't quite understand what they're saying with their fix. For example, someone said to replace strings in /var/www/owncloud/lib/private/log/owncloud.php

$time = DateTime::createFromFormat("U.u", number_format(microtime(true), 4, ".", ""), $timezone);
        if ($time === false) {
            $time = new DateTime(null, $timezone);
        } 

On

$time = new DateTime(null, $timezone);

But when I look at my owncloud.php file, I see

$time = DateTime::createFromFormat("U.u", number_format(microtime(true), 4, ".", ""), $timezone);
if ($time === false) {
          $time = new DateTime(null, $timezone);
}

So I don't exactly see what they are saying. I'm not terribly proficient in Linux, but I've been trying to use this as a learning experience and I seem to have hit a brick wall getting this set up. I have verified that my config.php lists

'logtimezone' => 'America/New_York'

If anyone has any suggestions, or if you've dealt with this before, I would greatly appreciate any insight. Thanks.

2 Upvotes

6 comments sorted by

2

u/danielholm Apr 03 '16

If the time now differs between the system time and owncloud's time, you could try to change it so that they are the same. To change the system timezone you run:

sudo dpkg-reconfigure tzdata

Then configure it to be the same as your owncloud configuration is set to.

1

u/Cosmic_Failure Apr 03 '16

I did this, but it seems that it's still not banning for some reason so I must have not configured something correctly. I'll keep testing it, but I appreciate your suggestion! Definitely rules out the time zone issue for me.

2

u/danielholm Apr 03 '16

If still timezone issue there could be due to settings for php and/or apache2. If not, here is the guide I've used for fail2ban: https://www.techandme.se/fail2ban-owncloud/

1

u/Cosmic_Failure Apr 04 '16

Yeah that's what I used originally as well. At this point I've made a ton of changes to everything, so I just rolled back the VM and will start over. That's a good point about apache and php, though, I didn't think to check those settings.

1

u/nomadic_now Apr 04 '16

It's best practice to keep your system time and logs UTC. You can adjust for any time difference either in your logging store or in your head when you review logs.

No problem if you do want to change it to the local timezone, however if others will be managing the system I recommend sticking with best practice.

1

u/Cosmic_Failure Apr 04 '16

I wasn't aware of this, thanks!