Specifying working directory when running a job from inside TOS

Four 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

Calling Talend Open Studio Users

The first 100 community members completing the Open Studio survey win a $10 gift voucher.

Start the survey

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 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

APIs for Dummies

View this on-demand webinar about APIs....

Watch Now