This guide needs root access. Root is the main admin login of your VPS.
What is a time zone?
The world is split into time zones. Each place has its own clock time. A VPS, or virtual private server, is your own slice of a bigger machine. It has its own clock setting. If the time zone is wrong, logs, emails and scheduled tasks show the wrong hour.
Check the current setting
- Log in to your VPS by SSH as root. SSH is a way to type commands on a server from your computer.
- Run this command.
It shows the date, time and time zone.timedatectl
If this command is not found on an older system, use date instead.
Set a new time zone
- List zones that you can choose.
This prints all names, liketimedatectl list-timezonesAsia/KolkataorAmerica/New_York. Pressqto leave the list. - Set your zone.
This changes the time zone. Replace the name with yours.timedatectl set-timezone Asia/Kolkata - Check again.
This should show the new time.date
Older systems without timedatectl
- Link the zone file.
This points the system clock to your zone.ln -sf /usr/share/zoneinfo/Asia/Kolkata /etc/localtime - Run
dateto check.
If it says permission denied or does nothing
Some VPS types are containers. A container shares its core with others, so the host machine may block changes to the clock. The host admin has to allow it. On OpenVZ, for example, the host needs the sys_time capability turned on for your container. If you cannot change the zone, open a ticket at https://secure.hostvento.com/submitticket.php and ask Hostvento support.
After the change
- Restart services that print times, such as web server and database.
- Check scheduled tasks.
Quick recap
- Check the time zone with
timedatectl. - Change it with
timedatectl set-timezone Zone/City. - Container VPS may need the host to allow it.
- Restart services and check scheduled tasks.