When working with CentOS 6.2 servers, you might encounter situations where the system timezone needs adjustment. The standard approach of symlinking /etc/localtime
to the appropriate zone file doesn't always work as expected in this version.
First, check your current timezone configuration:
# date
Wed Apr 18 15:43:28 GST 2012
# ls -l /etc/localtime
lrwxrwxrwx 1 root root 33 Apr 18 15:00 /etc/localtime -> /usr/share/zoneinfo/Asia/Dubai
For CentOS 6.2, you need to modify an additional configuration file:
# Update the symlink
ln -sf /usr/share/zoneinfo/Asia/Dubai /etc/localtime
# Edit the sysconfig clock file
echo 'ZONE="Asia/Dubai"' > /etc/sysconfig/clock
# Optional: Verify the change with zdump
zdump -v Asia/Dubai | head -n 1
# Restart system services that use timezone
service crond restart
service rsyslog restart
For interactive timezone selection:
# Run the timezone selector
tzselect
# Follow the prompts to select Asia/Dubai
# Then apply the selection
cp /usr/share/zoneinfo/Asia/Dubai /etc/localtime
After making changes, verify with these commands:
# Check current timezone
date
# Check timezone files
ls -l /etc/localtime
cat /etc/sysconfig/clock
# Check timezone database
timedatectl status # (Note: not available in CentOS 6)
To ensure the timezone persists across reboots and affects all users:
# Add to /etc/profile
echo 'export TZ=Asia/Dubai' >> /etc/profile
# Or for individual users:
echo 'export TZ=Asia/Dubai' >> ~/.bashrc
If timezone changes don't take effect:
# Check for running services that might cache timezone
ps aux | grep -E 'crond|rsyslog|ntpd'
# Verify the symlink points to the correct file
readlink -f /etc/localtime
# Check for conflicting environment variables
env | grep TZ
Remember that some applications may need to be restarted to pick up the new timezone. For systems running NTP, ensure your time synchronization is working properly:
# Check NTP status
service ntpd status
# Force immediate time sync
ntpdate pool.ntp.org
When working with CentOS 6.2 servers, you might encounter situations where the system timezone needs modification. The standard approach of symlinking /etc/localtime
doesn't always work as expected in this particular version.
First, check your current timezone settings:
# Check current timezone
date
# Output: Wed Apr 18 15:43:28 GST 2012
# View timezone file link
ls -l /etc/localtime
For CentOS 6.2, you need to modify additional configuration files:
# Step 1: Create the symlink (as you've tried)
ln -sf /usr/share/zoneinfo/Asia/Dubai /etc/localtime
# Step 2: Edit the sysconfig clock file
echo 'ZONE="Asia/Dubai"' > /etc/sysconfig/clock
# Step 3: Force time update
hwclock --systohc
For interactive selection, use the built-in tool:
# Run interactive timezone selector
tzselect
# Follow the prompts to select Asia → Dubai
# Then apply the selection:
TZ='Asia/Dubai'; export TZ
After making changes, verify with these commands:
# Check system time
date
# Check timezone configuration
cat /etc/sysconfig/clock
# For thorough verification
timedatectl status
If timezone changes don't persist after reboot:
# Check for cron jobs or services resetting timezone
grep -r "timezone" /etc/cron* /etc/init.d/
# Ensure NTP isn't interfering
service ntpd stop
chkconfig ntpd off
For scripting purposes, here's a complete one-liner:
# Single command to set Dubai timezone
ln -sf /usr/share/zoneinfo/Asia/Dubai /etc/localtime && \
echo 'ZONE="Asia/Dubai"' > /etc/sysconfig/clock && \
hwclock --systohc