Reputation: 81
When I use timedatectl to set the timezone, it happens
[root@localhost ~]# timedatectl set-timezone "America/New_York"
Failed to set time zone: Access denied
This's my host infomation
Static hostname: rolin
Icon name: computer-vm
Chassis: vm
Machine ID: 699591c5339c2ae6d7e7b25151eaa987
Boot ID: 40dc52c07c85444c9514f7d92a24448e
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-327.18.2.el7.x86_64
Architecture: x86-64
What can I do now?
Upvotes: 6
Views: 10268
Reputation: 1658
The root cause of this problem is probably an SELinux labeling issue. The fix is to relabel the /etc directory:
restorecon -Rv /etc
Then re-run the timedatectl command.
Source: https://access.redhat.com/solutions/3366211 (link requires a RedHat login).
Or if you can't do that for some reason, as a workaround you could temporarily set SELinux to permissive mode, update the time zone, and then re-enable SELinux.
However, that second approach will not fix the underlying problem. A mis-labeling in /etc may well cause other problems down the road.
Upvotes: 9
Reputation: 194
I used this commands to change timezone for my vicidial server with cent os 7 :
rm /etc/localtime
rm: remove regular file `/etc/localtime'
ln -s /usr/share/zoneinfo/Europe/Rome localtime
date and you will see that it is changed.
Upvotes: 2
Reputation: 81
I find that my /etc/localtime is not a symbolic links pointing to /usr/share/zoneinfo/... .
so I changed that file like this ,it works:
lrwxrwxrwx. /etc/localtime ->../usr/share/zoneinfo/Asia/Shanghai
Upvotes: 1