Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Independent validation for trusted, AI-ready data integration. See why IDC named Qlik a Leader: Read the Excerpt!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to add date and jobName to logName in bat

I would like to set ,in build bat setting in the project property, date and jobName to output log file  like below.

How can I do this?

 

%~d0
cd %~dp0
java -Dtalend.component.manager.m2.repository=%cd%/../lib ${talend.job.jvmargs} -cp ${talend.job.bat.classpath} ${talend.job.class} ${talend.job.bat.addition} %* >> log_YYYMMDD_jobName.txt  2>>&1

 

Labels (3)
5 Replies
DataTeam1
Creator
Creator

You can try to do this creating context variable and use it in bat file as bellow:

 

0683p000009M3v8.jpg

 

And inside bat file you will see

 

0683p000009M3vD.jpg

 

But I think, better way is using tJava component and create the filename automaticaly (instead of setting it in bat file) as bellow:

 

context.Parameter1 = "log_" + TalendDate.formatDate("yyyyMMdd_", TalendDate.getCurrentDate()) + jobName + ".txt";

 

 

Anonymous
Not applicable
Author

I would like to set all in bat.  I find ${talend.job.name} can retrieve the jobname.

How about YYYYMMDD  ?  Is this retrieved by something like %date% ?

 

set YYYYMMDD=....

%~d0
cd %~dp0
java -Dtalend.component.manager.m2.repository=%cd%/../lib ${talend.job.jvmargs} -cp ${talend.job.bat.classpath} ${talend.job.class} ${talend.job.bat.addition} %* >> log_YYYYMMDD_${talend.job.name}.txt  2>>&1

akumar2301
Specialist II
Specialist II

try this 

set YYYYMMDD=%date:~10,4%%date:~3,2%%date:~0,2%

Anonymous
Not applicable
Author

I've heard date command depends on the environment. How confirm date setting is YYYY , not YY, for example ?
akumar2301
Specialist II
Specialist II

You are right , it is complicated in batch program if you are not sure of ShortDate format.

 

https://www.robvanderwoude.com/datetimentparse.php

 

I would suggest to use other utility like perl/groovy etc if you have in your environment.