Difference between revisions of "How to change server time zone"
(Created page with 'Check current time by entering date into console. '''Available timezones could be found in /usr/share/zoneinfo''' You have to choose correct timezone file and copy it on top…') |
|||
(3 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
= Centos 6 = | |||
Check current time by entering | Check current time by entering | ||
Line 12: | Line 13: | ||
cp /usr/share/zoneinfo/Europe/Dublin /etc/localtime | cp /usr/share/zoneinfo/Europe/Dublin /etc/localtime | ||
Update /etc/sysconfig/clock to new timezone, in this example it would look like this: | |||
$> cat /etc/sysconfig/clock | |||
ZONE="Europe/Dublin" | |||
Note: if /etc/sysconfig/clock file is not updated, certain commands (for example glibc package update) will revert timezone to the one defined in /etc/sysconfig/clock, so do not skip this step. | |||
Next step, change hardware clock time to your localtime: | Next step, change hardware clock time to your localtime: | ||
Line 20: | Line 27: | ||
hwclock --show | hwclock --show | ||
Restart rsyslog: | |||
service rsyslog restart | |||
Then '''restart asterisk''', if this doesn't help, restart your server. | Then '''restart asterisk''', if this doesn't help, restart your server. | ||
= Centos 7 = | |||
1. Check the current timezone with | |||
date | |||
timedatectl | |||
2. Get the list of available timezones | |||
timedatectl list-timezones | |||
3. Set timezone from one from the list | |||
timedatectl set-timezone Country/City | |||
4. Verify changes with | |||
timedatectl | |||
5. Restart rsyslog | |||
service rsyslog restart | |||
After changes, it is recommended to restart asterisk, httpd, mysqld, or reboot the server. | |||
=See also= | |||
*[[GUI time zone]] |
Latest revision as of 07:11, 26 August 2022
Centos 6
Check current time by entering
date
into console.
Available timezones could be found in /usr/share/zoneinfo
You have to choose correct timezone file and copy it on top of /etc/localtime file.
Example if your server is in Dublin , Europe:
cp /usr/share/zoneinfo/Europe/Dublin /etc/localtime
Update /etc/sysconfig/clock to new timezone, in this example it would look like this:
$> cat /etc/sysconfig/clock ZONE="Europe/Dublin"
Note: if /etc/sysconfig/clock file is not updated, certain commands (for example glibc package update) will revert timezone to the one defined in /etc/sysconfig/clock, so do not skip this step.
Next step, change hardware clock time to your localtime:
hwclock --systohc
Check hardware clock time by running:
hwclock --show
Restart rsyslog:
service rsyslog restart
Then restart asterisk, if this doesn't help, restart your server.
Centos 7
1. Check the current timezone with
date timedatectl
2. Get the list of available timezones
timedatectl list-timezones
3. Set timezone from one from the list
timedatectl set-timezone Country/City
4. Verify changes with
timedatectl
5. Restart rsyslog
service rsyslog restart
After changes, it is recommended to restart asterisk, httpd, mysqld, or reboot the server.