Page 1 of 1

Attach datetime to file after succesful completion of job

Posted: Wed Nov 23, 2005 1:44 am
by Ananda
hi,

I have a parallel job. Input is a file stage and the data is populated into a table through Teradata stage.

I need to take a backup of the files processed with a timestamp attached to it at runtime after successful completion of the job without hardcoding the timestamp in Job porperties.

Is there any built in function that I can use to have the current timestamp and assign it to a variable in Job properties.

Please let me know in case of any pointers.

regards
anand

Posted: Wed Nov 23, 2005 1:49 am
by ArndW
Where do you need this timestamp? DS Jobs will let you use @DATE and @TIME to get the current time into a variable for use within a job. You can use the corresponding OS functions if you shell out to perform file copy operations. "Job Properties" is a designer box, and apart from the parameters there isn't anything that I recall in there that changes during job runs.

Posted: Wed Nov 23, 2005 2:28 am
by Ananda
hi,

I have a set of input files with data that needs to be moved into a Teradata table after regular intervals of time.

All the input files before getting processed will be moved to the same file path and will be having the same file name.

Once the data from a file is moved into the table, the file is moved to an archive directory with timestamp attached.
e.g #pFILENAME#.#pTIME#

where pFILENAME = file name processed
pTIME = current timestamp

I am trying the unix command 'mv' using After sub-routine to move the file to an archive directory but not able to attach the current timestamp to the file.

I tried @TIME as default value for the variable pTIME with data type as TIME, but when run it is asking for a value. Same with @DATE.

Any pointers.

Thanks

Posted: Wed Nov 23, 2005 8:16 am
by ashwin2912
You can use in UNIX:

Code: Select all

date +%Y-%m-%d-%H:%M:%S
But I guess you would need to call a script to concatenate it with the file you are mving.

Posted: Wed Nov 23, 2005 10:36 am
by Ananda
There is no script that needs to be involved. This is because in our current deisgn of the project there are no unix scripts. I need to handle this with the DataStage job itself..

And since I am using the "mv" command to move the file in the job properties I need to devise how to pass the current timestamp in 'job properties' itself.

I agree that using unix script it would have been possible, but no unix script needs to be involved. Everything needs to be handled within the DataStage job itself.

Please let me know if there are any pointers.
Thanks

Posted: Wed Nov 23, 2005 5:05 pm
by jenkinsrob
If you are using a mv command in an After-Job Subroutine you can do the following:

Code: Select all


mv <Source_Dir>/<Your_File> <Target_Dir>/<Your_File>`date '+%Y-%m-%d:%H:%M:%S'`

The ExecSH option should be selected.

Posted: Wed Nov 23, 2005 5:12 pm
by Ananda
Thanks a ton jenkinsrob and all,

The issue is now resolved

regards
Anand