Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Server timezone into Python Script Component

Hi,

What is the right way to set my server timezone into Python Script Component?

Thanks

5 Community Answers

Matillion Agent  

Laura Malins —

Hi Everton

You can set the linux server timezone using this guide:
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/set-time.html

This could be done in the bash component in Matillion but I’d recommend just SSHing onto the EC2 instance and setting it manually.

Could you share some more details on your use case here? Is there a reason you want to reset the timezone using Matillion and specifically Python?

Thanks
Laura


Everton Portela —

I'm creating a job with just a Python Script Component inside, that uses boto3 to restart some AWS services.

When I use the logging library to produce the output, the time is shown without the timezone offset, as Matillion does.

In summary, I just wanna show the same time into the log accordingly to the time show by Matillion for each component of the job.

In the code example below, 'asctime' is evaluated to the current server time, which is 3 hours ahead my localtime (Matillion apply the timezone correctly):

<code>

formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')

</code>

Thanks,

Everton


Matillion Agent  

Ian Funnell —

Hi Everton,

If you’re using either the Python 2 or Python 3 interpreters, you just need to add a line to set your timezone, for example:

os.environ['TZ'] = 'Europe/London'

If you’re using Jython I’m not sure it’s possible except by writing a custom formatter.converter. Jython timezone is set by the underlying JVM, and Matillion requires that this stays as UTC.

Best regards,
Ian


Everton Portela —

Ian,

We set the linux timezone as Laura suggested. Both Matillion and Python Logging library is showing correctly the timestamps now, but you message let me worried if I'll have some issue doing that way.

I'm using Mattilion ETL version 1.24.6 (build 55), AMI version 1.24.6. This Matillion version doesn't have choice between Jython and Python 2/3.

Please, let me know if I need to revert the linux timezone.

Regards,

Everton


Matillion Agent  

Ian Funnell —

Hi Everton,

My main concern with setting the timezone on Linux was in case it led to a problem with your scheduler or Task History timings. As long as they are still working correctly then there’s no problem at all with doing that.

Matillion 1.27 does have the ability to choose between Jython and Python 2/3, so if you get a chance to update Matillion then you’ll have access to this (and other) new functionality

Best regards,
Ian

Post Your Community Answer

To add an answer please login