I have set the date & time but once I logout, it sets time back to old time slot.
How can I set the time permanently? I have used the tzselect command & then export localtime.
I have set the date & time but once I logout, it sets time back to old time slot.
How can I set the time permanently? I have used the tzselect command & then export localtime.
If systemd based system, here you are ↴
$ timedatectl set-time 'YYYY-MM-DD HH:MM:SS'
And if you want to change the date or time only:
$ timedatectl set-time HH:MM:SS /*for time only*/
$ timedatectl set-time YYYY-MM-DD /*for date only*/
To verify the change:
$ timedatectl
To print the system date and time:
$ date
You can use timedatectl as shown below to list the available timezones
$ timedatectl list-timezones
To select one:
$ timedatectl set-timezone 'yourNewTimeZone'
N.B. And if you want to use tzselect, be aware that for the change to be permanent, you need to add your export-line - for instance TZ='yourNewTimeZone'; export TZ in $HOME/.bash_profile or $HOME/.bashrc. BTW, be aware that tzselect command does not actually change the timezone for you.
timedatectl set-ntp no, set the time, then set the hardware clock hwclock -w, then turn on back the ntp timedatectl set-ntp yes, assuming you already have correct timezone