When running a VPS or leased dedicated server, you may find that the timezone does not match your own. You may or may not also find that your new server has the correct date. With Linux servers, you can change the date and timezone with a few simple commands.
Why is this important? When you schedule backups, updates, and other important future events based on your own timezone, you will always have to compensate for the time difference. But if you change the timezone on your server to match your own, you will not have to worry about compensating.
The “date” command allows you to see the current date and time and also change it to whatever you specify. To see the current date and time, just type the following command:
date
The output will look like this:
Wed Jul 21 13:06:17 EDT 2010
To change the date, time, or both, enter “date -s” followed by the date and/or time you want to set. For example:
date -s "21 Jul 2010 18:00:00"
To set only the time without changing the date, enter:
date +%T -s "10:13:13"
To change the date alone in simplified format, type:
date +%Y%m%d -s "20081128"
In Red Hat Enterprise Linux (RHEL), Fedora, and CentOS, you can easily change the timezone with the command:
redhat-config-date
For Debian servers, use:
tzselect
Once your time and timezone are set correctly, you should never have to reconfigure them, even if your server is rebooted. Now any time you schedule tasks or any other important events, your server will match your local time.