Specifying working directory when running a job from inside TOS

Five Stars

Specifying working directory when running a job from inside TOS

Hi
I have the requirement to use absolute paths. When exporting TOS jobs logs are created in the folder I export the job to, and this works fine.
However, when I run the job from inside TOS log files are written in the TOS Installation directory. I need to specify a different working directory to which logs and files have to be stored.
Specifically, I am using a tFileOutputDelimited component with filename property = to
".//LOG//LOG_" + jobName + "_" + TalendDate.getDate("yyyyMMdd_HHmm") + ".log"
is that possible? is there a configuration item I am missing?
thank you
Shine
Four Stars

Re: Specifying working directory when running a job from inside TOS

shinesei - you're absolutely on the right path... To make it even better, create a context variable and assign it the default directory path, for example, context.workingDirectory = "//ServerName/Directory1".
Wherever you need to write to that directory, you'd use
context.workingDirectory + "/" + jobName + "_" + TalendDate.getDate("yyyyMMdd_HHmm") + ".log"
This way, you can change that working directory on the fly...
Seventeen Stars

Re: Specifying working directory when running a job from inside TOS

hi all,
and to go further and follow willm said , by that way you can assign value for you contexte variable "on the fly" in your script file with :
context_param workingDirectory=/absolutePath/files/logs

depending on your environment execution (dev,int,prod,etc)
regards
laurent
Four Stars

Re: Specifying working directory when running a job from inside TOS

Hi,
I have experimented with one more good idea to use system variable...
System.getProperty("user.dir")+"/_logs/");
This creates a directory for me to log. If it is in TOS, then current directory or when exported, it would use the exported current directory...
I found it more useful... Again this value is set into the routine and I am calling the routine for log file path... Even you can use some context variable if needed for the purpose of dynamic log folder name.
Thanks
Vaibhav

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog