Using %%PRECMD and %%POSTCMD

All questions about Control-M jobs definitions
Post Reply
User avatar
planteam
Nouveau
Nouveau
Posts: 8
Joined: 07 Oct 2010 12:00

Using %%PRECMD and %%POSTCMD

Post by planteam » 14 Jun 2012 7:48

Hi all!


We have several cases where, in case of job error, we want to run a simple line command to "clean up" messy logs the job might (or not) have left behind:
rm my_job_XXXXX.log
As there isn't a "DO Command" option on the "Steps" tab, we did some research and found the %%PRECMD and %%POSTCMD variables.

The %%POSTCMD seemed appropriate for what we want:
Specifies a command to run immediately after running the job defined by MEMNAME. The return code is ignored.

However, it seems that the post command only executes after <b>successful execution</b> of the said job. Can anyone confirm this?

If so, are there any alternatives other than forcing an extra job to do this "clean up" business?

Thanks! ~:)

User avatar
rpetersonesq
Nouveau
Nouveau
Posts: 5
Joined: 05 Jan 2009 12:00
Location: Salt Lake City, UT

Post by rpetersonesq » 21 Jun 2012 10:50

The other thing about the 'POSTCMD' is it runs before the steps tab. For instance, I tried to run a postcmd against a filewatch jobs sysout to parse the file name (I was using a mask in the FW). But the 'Do Sysout' to create a log file wasn't done when the postcmd tried to parse it. So I had to use a 'PRECMD' in the successor job to run the script to isolate the file name so I could set a variable to pass as input to the script.

Post Reply