Debian – I have three different timezones on the Debian Linux

apache-httpddebiansyslogtimezone

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?

Best Answer

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.)

Related Question