It's important to keep your server's time and date correct and in-sync, so that logs and visitor activities all tally up. Thankfully, it's a very easy task to do.
Step 1: Set your timezone
The first step is to ensure you're using the correct timezone. You might want to use your home location's timezone, or stick with something universal like UTC. For purposes of demonstration, we'll show two examples and you can use/tweak whichever is most appropriate for you:
cp /usr/share/zoneinfo/UTC /etc/localtime
This will overwrite the localtime file with the UTC timezone. This is recommended for web and production servers for PCI compliance.
cp /usr/share/zoneinfo/Europe/London /etc/localtime
This will overwrite the localtime file with the Europe/London timezone. You can also specify other timezones, for example "America/New_York" or whichever timezone of your choice.
Step 2: Install ntpd
NTPd is the server daemon/service that runs in the background and frequently checks the date and time. Installation is very simple:
yum install ntpd
Once installed, we'll want to ensure NTPd runs every time the server is booted up:
chkconfig ntpd on
And finally we want to start ntpd immediately so that it can begin syncing our time:
service ntpd start
Step 3: Sync the time
The last step is to sync the time right now. It's also super-simple to do:
And that's it! Your server time is up to date and will always be in-sync. Well done!