I use Debian 9.5.1. I used the dpkg-reconfigure tzdata command to set my timezone to Tehran.

Now I have three timezones in my Linux. I execute the following three command together and look at logs:

root@debian:~: date
Mon Feb 18 14:01:21 +0330 2019

root@debian:~: tail -f /var/log/syslog
Feb 18 05:31:22 debian systemd[1]: Stopping Raise network interfaces...

root@debian:~: tail -f /var/log/apache2/error.log
2019-02-18 10:31:22 Error: Sms.Outbox

What I must do to sync all with my timezone?

  • 1
    You have restarted hosts ? (running process might stil have old data) – Archemar Feb 18 '19 at 11:12
  • 1
    Apache Log Format can be changed with the %{format}t directive. See Common Log Format / Custom Log Formats. But your date format is the best if you try to find an error at a given time. – Freddy Feb 18 '19 at 11:40

Most programs read the timezone settings once at start-up and won't expect them to change while the program is running.

So, you'll need to restart any programs with incorrect timezone:

root@debian:~: systemctl restart rsyslog

root@debian:~: systemctl restart apache2

You should also update the initramfs file, so that the correct timezone will be set as early as possible in the boot process:

root@debian:~: update-initramfs -u

It looks like Apache might be using the UTC timezone. That might be intentional: it is possible to use the TZ environment variable to set a specific timezone to specific programs, if e.g. some sort of log post-processing requires the logs of some services to be in UTC time. This might be set in /etc/apache2/envvars.

Your syslog daemon might be using the US Eastern timezone. That is a common "factory default" for US-centric software, and is probably what your timezone was set to before you changed it to Tehran.

(I would have expected Debian to use UTC as the factory default instead, but perhaps there are some historical backwards compatibility reasons why not.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.