Attach datetime to file after succesful completion of job

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
Ananda
Participant
Posts: 29
Joined: Mon Sep 20, 2004 12:05 am

Attach datetime to file after succesful completion of job

Post 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
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post 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.
Ananda
Participant
Posts: 29
Joined: Mon Sep 20, 2004 12:05 am

Post 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
ashwin2912
Participant
Posts: 57
Joined: Wed Jan 26, 2005 10:22 pm
Location: India

Post 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.
Ashwin
Ananda
Participant
Posts: 29
Joined: Mon Sep 20, 2004 12:05 am

Post 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
jenkinsrob
Participant
Posts: 31
Joined: Mon Dec 01, 2003 6:24 am
Location: London

Post 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.
Ananda
Participant
Posts: 29
Joined: Mon Sep 20, 2004 12:05 am

Post by Ananda »

Thanks a ton jenkinsrob and all,

The issue is now resolved

regards
Anand
Post Reply