Skip to main content

Timezone restore in Linux

We got problem in Centos 6 server with plesk panel,

Timezone got reset frequently on one that server, I've found the issue on update of tzdata package, Working on it to find permanent solution, But in mean time I've used following script for reset timezone.

# /bin/sh
TZ=`date '+%Z'`
CTIME=` date '+%Y/%m/%d'-'%T'`
if [[ "$TZ" != IST ]] ; then
touch /var/log/timezone-script.log
echo "["$CTIME"]" "Current time-zone is" $TZ "and Needs to change" >> /var/log/timezone-script.log
rm -f /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Kolkata /etc/localtime
else
echo "["$CTIME"]" "Current time-zone is" $TZ "and Working fine" >> /var/log/timezone-script.log
fi
Change your timezone what you need, I'm using IST and using log file to know status. Even we can use mail function on it.
 Default location of timezone is /usr/share/zoneinfo/ 

Comments