A Easy Way Of Configure Timezone In Databases From Unix

This morning talking with a partner raised the issue of having several databases at different timeszones in the same Unix machine. There are many ways to do this, some more correct than others. In this case I want show an example using the operating system (in this example I use a Solaris 11.3) this will make us independent of the database engine (Oracle, Sybase, SQL Server on linux) that we use, although all the databases have a mechanism for perform this function from inside the engine of database and that is a mandatory feature of the ISO 9075 standard (or ANSI SQL for the USA).

In Solaris by default, if we do not specify anything, when we create a user and we do not tell him anything he will use the machine, we can see it in the /etc/TIMEZONE file

 
Ghost> cat /etc/TIMEZONE
#
# Copyright 1992, 1999-2002 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
#ident  "@(#)init.dfl   1.7     02/12/03 SMI"
#
# This file is /etc/default/init.  /etc/TIMEZONE is a symlink to this file.
# This file looks like a shell script, but it is not.  To maintain
# compatibility with old versions of /etc/TIMEZONE, some shell constructs
# (i.e., export commands) are allowed in this file, but are ignored.
#
# Lines of this file should be of the form VAR=value, where VAR is one of
# TZ, LANG, CMASK, or any of the LC_* environment variables.  value may
# be enclosed in double quotes (") or single quotes (').
#
TZ=UTC
CMASK=022

 

If we execute a date at the level of the prompt;

Ghost> date
Tue Feb 13 16:14:00 UTC 2018

 

If we login to the same machine but with another user and we see his file .profile where we have defined the variable TZ;

Ghost> cat .profile

export TZ=Europe/Madrid

If we execute a date at the level of the prompt;

Ghost> date
Tue Feb 13 17:15:17 CET 2018

 

Once we have defined the variable TZ we can create/start the database and it must take this time.

HTH – Antonio NAVARRO

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s