ctmdefine

The ctmdefine utility is an API that adds a job processing definition to one of the following folders in the database:

  • A regular folder.

  • A SMART folder.

  • A sub-folder.

The ctmdefine utility can be used when converting job scheduling information from other job control components to the Control-M/Server. The function performed by this utility is equivalent to the manual process of creating job processing definitions, as described in Job definition.

The ctmdefine utility can be invoked using the -input_file parameter:

-ctmdefine -input_file <fullPathFileName>

The referenced file contains all the required parameters. Most of the parameters are described in ctmdefine Parameters.

For information about ctmdefine syntax rules, see ctmdefine Syntax Rules.

The ctmdefine utility can also be used to define jobs for specific applications, for example, SAP and Oracle Applications (OAP).

When creating new SMART folders or job processing definitions using this utility, consider the following:

  • If the job name specified already exists in a job processing definition in the SMART folder, the new job processing definition does not overwrite the existing one. Both job processing definitions appear in the folder, each with a different internal job number.

  • If the SMART folder does not exist, the utility creates it.

  • After using this utility to create one or more job processing definitions, download the modified SMART folders to the Control-M/EM database.

  • A newly created SMART folder can be assigned an Order Method parameter using Control‑M client after the folder is downloaded to the Control-M/EM database or by using the ctmpsm utility.

  • Values for a creation/modification timestamp and the user ID of the user who created or modified the job processing definition are automatically added to the communication protocol between Control‑M/EM and Control-M/Server and are stored in the Control‑M/EM database. These values are initialized by the ctmdefine utility and are sent to Control‑M/EM when the SMART folder is downloaded. When the SMART folder is uploaded, Control‑M/EM sends these values to Control-M/Server.

  • When defining a job in a nested folder, a folder path to the intended nested folder must be specified (-FOLDER option). The folder path starts from the outermost folder name and is similar to operating system files and directories path. When a folder name is used and the folder does not exist, a folder is created.

  • If you define a new Rule-based calendar with the ! character at the beginning of the Rule-based calendar name, the Rule-based calendar is excluded. If this feature is disabled, an error message is displayed that you cannot define a Rule-based calendar with the ! character. For more information, see DefaultCTMExcludeRBC in Control-M/EM general parameters.

Adding a Job to a Folder Using the ctmdefine Utility

This procedure describes how to run the ctmdefine utility, which enables you to add a job processing definition to a folder, a SMART folder, and a sub-folder in the Control-M/Server database.

Begin

  1. Do one of the following:

    • UNIX: Log in to a Control-M/Server account.

    • Windows: Open a command prompt window where Control-M/Server is installed.

    You can also run this utility in Control-M Agent by navigating to where Control-M/Agent is installed.

  2. Type the following command:

    Copy
    ctmdefine
    -FOLDER <name>
    -JOBNAME <name>
    -TASKTYPE <JOB|EXTERNAL|DETACHED|COMMAND|DUMMY>
    -SUB_APPLICATION <sub_application name>
    -APPLICATION <applic name>
    [ -CMDLINE <string> ]
    [ -EMBEDDED_SCRIPT <file name> ]
    [ -MAXRERUN <value> ]
    [ -CRITICAL Y|N ]
    [ -END_FOLDER Y|N ]
    [ -CYCLIC Y|N ]
    [ -CYCLIC_TYPE INTERVAL|INTERVAL_SEQUENCE|SPECIFIC_TIMES ]
    [ -INTERVAL <45d(days) | 1080h(hours) | 64800m (minutes)> ]
    [ -SPECIFIC_TIMES <specific times string (HHMM,HHMM)> ]
    [ -INTERVAL_SEQUENCE <interval sequence string e.g(+1H,+2M)> ]
    [ -TOLERANCE <maximum delay allowed (minutes)> ]
    [ -INTERVALFROM START | END | TARGET ]
    [ -OVERRIDE_PATH <alternative directory> ]
    [ -RELATIONSHIP AND|OR ]
    [ -MAXWAIT <days> ]
    [ -HOSTGRP <name> ]
    [ -FILE_PATH <path> ]
    [ -FILE_NAME <filename> ]
    [ -MULTIAgent Y|N ]
    [ -ADJUST_COND Y|N|B]
    [ -RUN_AS <username> ]
    [ -CREATED BY <username> ]
    [ -DEBUG <debug level 0-5> ]
    [ -QUIET ]
    [ -TIMEZONE <xxx> ]
    [ -TIMEFROM <earliest submission time> ]
    [ -TIMEUNTIL <latest submission time> | '>' ]
    [ -PRIORITY <job priority> ]
    [ -CONFIRM Y|N ]
    [ -TASKCLASS DISTRIBUTION_|DECOLLATION
    [ -APPLTYPE <Agent_application> ]
    [ -APPLVER <application version> ]
    [ -CMVER <CM version> ]
    [ -APPLFORM <application form> ]
    [ -DESCRIPTION <string> ]
    [ -DOCMEM <filename> ]
    [ -DOCLIB <directory name> ]
    [ -INCOND <condition> <dateref>|ODAT AND|OR ]
    [ -OUTCOND <condition> <dateref>|ODAT ADD|DEL ]
    [ -VARIABLE <variable name as %%local, %%\global, %%\\smart or %%\\pool\variable> <expression> ]
    [ -QUANTITATIVE <name> <quantity> ]
    [ -OUTPUT RELEASE|DELETE|COPY|MOVE [<parameter>]]
    [ -CONTROL <name> E|S ]
    [ -SHOUT OK|NOTOK|RERUN|LATESUB|LATETIME|EXECTIME <destination> <urgency R|U|V> <message> [<time>| <#mmm>] ]
    [ -ON <statement> <code>|
    <varname> <operator EQ|NE|GT|GE|LT|LE|IR|NR|LK|NL|IX|NX|SW|EW|CO|NC|MP|NP> <value>
    [ -DOOK ]
    [ -DONOTOK ]
    [ -DORERUN ]
    [ -DOOUTPUT RELEASE|DELETE|COPY|MOVE [<parameter>] ] ]
    [ -DOSTOPCYCLIC ]
    [ -DOSHOUT <destination> <urgency R|U|V> <message> ]
    [ -DOCOND <condname> <dateref>|ODAT ADD|DEL ]
    [ -DOVARIABLE <variable name as %%local, %%\global, %%\\smart or %%\\pool\variable> <expression> ]
    [ -DOFORCEJOB <foldername> <jobname> <odate>|ODAT[-UNIQUE_FLOW Y|N]]
    [ -DOREMOTEFORCEJOB <foldername> <jobname> <odate>|ODAT [-UNIQUE_FLOW Y|N ]]
    [ -ORDERVARIABLE <variable name as %%local, %%\global, %%\\smart or %%\\pool\variable> <expression> ]
    [ -DOMAIL <destination> <cc> <urgency R|U|V> <subject> <message> [<attach output>] ]
    [ -DOREMEDY <summary> <description> <urgency L|M|H|U|C> ]
    [ -CAPTURE INTO <variable name as %%local,%%global,%%\\smart or %%\\pool\variable>
    SEARCH <Search string>
    [ SKIPROWS <Number rows>]
    [ SKIPWORDS <Number words> [DELIMITER <Character delimiter> TAKE <Number words|0 until end>]|SKIPCHARS <Number characters> [TAKE <Number chars|0 until end>]]]
    [ -DAYS <daystr> ]
    [ -WEEKDAYS <weekdaystr> ]
    [ -MONTH ALL|JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC Y|N ]
    [ -DATE <MMDD> ]
    [ -DATEFROM <YYYYMMDD> ]
    [ -DATEUNTIL <YYYYMMDD> ]
    [ -DAYSCAL <calendar> ]
    [ -WEEKCAL <calendar> ]
    [ -CAL_ANDOR AND|OR ]
    [ -SHIFT [</>/@][+/-]nn ]
    [ -CONFCAL <calendar> ]
    [ -RETRO Y|N ]
    [ -RBC <rule_based_calendar> ]

If you define a new Rule-based calendar with the ! character at the beginning of the Rule-based calendar name, the Rule-based calendar is excluded. If this feature is disabled, an error message is displayed that you cannot define a Rule-based calendar with the ! character. For more information, see DefaultCTMExcludeRBC in Control-M/EM general parameters.

Defining Application-Specific Jobs

The ctmdefine utility can be used to define jobs for specific applications, for example, SAP and Oracle Applications. These jobs are defined by setting the -appltype parameter to, for example, SAP or OAP.

The -file_name and -file_path parameters must also be specified for the ctmdefine utility when defining application-specific jobs.

In addition to these parameters, you can specify application-specific parameters as variables. These variables are described in detail in the SAP and Oracle Applications user guides.

ctmdefine -tasktype job -jobname sap1 -File_Name test -File_Path sap -VARIABLE %%SAPR3-JOB_MODE CREATE -VARIABLE %%SAPR3-ACCOUNT DV2 -VARIABLE %%SAPR3-STEP-S01-PROGRAM ZQA_SIMPLE -run_as sapr3 -VARIABLE %%SAPR3-STEP-S01-STEP_TYPE A -APPLTYPE SAP -hostgrp nord -VARIABLE %%SAPR3-JOBNAME sap1 -folder SAP1 -application SAP1 -sub_application SAP1

ctmdefine Parameters

The following table describes the debug, quiet, and input_file parameters. All other parameters (for example, cyclic job parameters) are described in Control-M Parameters.

Parameter

Description

-APPLICATION

Provides a logical name for sorting groups of jobs. This parameter is used to supply a common descriptive name to a set of related groups of jobs.

-CREATED_BY

Defines the Control‑M/EM user who defined the job.

This argument is used by the Control-M/Server security mechanism and, under certain circumstances, cannot be modified. For more information, see the Security chapter and the description of the AuthorSecurity system parameter in GUI Server parameters.

-debug

Determines the level of debug messages.

Valid values: 0 to 5

Default: 0 — no debug messages

-quiet

Disables information messages during execution of the command.

-input_file

Defines the name and full path of a file containing parameters for the utility. In this file, each parameter and its values (if any) are on a separate line with the same syntax they would have on the command line. Using the -input_file parameter enables you to:

  • Prepare and save files of utility parameters that can be reused.

  • Specify utility input longer than the number of characters allowed in the command line.

-input_file ~<controlmOwner>/ctm_server/data/ctmdefine_parms.txt

-CAPTURE

Defines the job capture definitions. This parameter can be used to search the output of a job for specified text and based on the capture parameters, extract words or characters from the output. The destination of the capture is a variable that can be set to any of the following types:

  • Local

  • Global

  • Named Pool

  • SMART folder

into: Defines the target variable of the CAPTURE action. Use one of the following variable types to enter the variable name:

  • %%varname: local variable

  • %%\varname: global variable

  • %%\\poolname\varname: named pool

  • %%\\varname: SMART folder

Maximum characters in variable name: 38

Maximum characters in pool name: 40

There is no default value. A value must be specified

search: Defines the string in the output file to begin the capture process.

Maximum characters: 64

There is no default value. A value must be specified

skiprows: Defines the number of lines to skip from the search string in the output file.

Maximum skip rows allowed: 99999999

Default: 0

skipwords/skipchars: Defines the number of words or characters to skip from the search string in the output file. Select skipwords or skipchars.

Maximum skipwords/skipchars: 99999999

Default: 0

delimiter:(Only relevant for skipwords) Defines the character type that marks the beginning/end of the string.

Valid values:

  • white space

  • space

  • tab

Default: white space

take: Defines the string to capture.

Valid values:

  • <number of characters>/<number of words>

  • 0: indicates until end of line

Maximum take words/characters: 4000

Defaults:

  • skipchars: 0

  • skipwords: 1

-DOMAIL

Sends mail when the job run is complete. Optional.

DOMAIL urgency="R" destination="[email protected]" cc="[email protected]" subject="OK" message="Task completed OK."

destination: Recipient of the message.

cc: Optional additional recipient of the message.

urgency: Urgency of the message.
Valid values:

  • R: regular

  • U: urgent

  • V: very urgent

subject: Brief text description of the message contents.

message: Text of the message.

attach output: Specifies at the job level whether the OUTPUT should be sent as an email attachment.

Valid values:

  • Y: Yes

  • N: No

  • D: default. Takes the value from the Control-M/Server configuration file.

ctmdefine Syntax Rules

The following syntax rules apply for this utility:

  • More than one parameter can be specified on a line.

  • Keywords can be written in either uppercase or lowercase, but parameter values are case sensitive.

-sub_application ACCGROUP and -SUB_APPLICATION ACCGROUP

specify the same sub application ACCGROUP.

-sub_application accgroup

specifies a different sub application accgroup.

  • For the -month parameter, specify the first three letters of a month (for example, JAN) or ALL for all months (the default is none). To specify two or more individual months, use a separate -month parameter for each month.

  • If a single character is specified for the priority parameter, the first character is assumed to be A. For example, priority 1 is interpreted as priority A1.

  • The length of the command line, after decoding, must not exceed 999 characters.

  • Although most parameters are listed as optional, certain parameters may be required, depending on the option specified for parameter tasktype.

  • All task types require the sub application and application parameters.

    • TASKTYPE JOB and DETACHED require parameters file name and file path.

    • TASKTYPE COMMAND requires parameter cmdline.

    • FOLDER requires the RBC (Rule-based calendar) parameters. Each RBC definition is followed by its scheduling parameters. If a Rule-based calendar is defined with the ! character at the beginning of the Rule-based calendar name, the Rule-based calendar is excluded. If this feature is disabled, an error message is displayed that you cannot define a Rule-based calendar with the ! character. For more information, see DefaultCTMExcludeRBC in Control-M/EM general parameters.

-rbc myrbc1
-maxwait 1
-days 0,2,3
-dayscal cal1

  • Strings containing blanks must be enclosed in quotation marks (for example, cmdline "ctmudlst list payroll").

  • A UNIX metasymbol (that must be enclosed in quotation marks) in a command line string should be enclosed in single quotation (for example, cmdline "ctmcontb list ‘*’").

  • If a parameter value begins with a $ sign, the operating system will try to replace the value. For example, -jobname $USER will cause the shell to substitute the current user. If a parameter value should contain a $ sign, enclose the value in single quotation marks. For example, -jobname ‘test$’ will set the jobname parameter to test$.

  • A variable that does not contain a $ sign can be enclosed in single or double quotation marks. A variable that does contain a $ sign should be enclosed in single quotation marks. A variable containing a $ sign cannot be resolved if it is enclosed in double quotation marks.

  • Condition dates are specified in mmdd format. Time is specified in hhmm format.

  • On computers that support Disk Clustering, the -hostgrp parameter is required (including either a host group name, or the virtual name of the ControlM/Agent).

  • A parameter requiring more than one entry can be repeated as needed:

    • If a job is dependent upon several prerequisite conditions, specify a separate incond parameter for each prerequisite condition.

    • If a job can run only in January and July, specify a separate -month parameter for each month. (For example, -monthALLN month JAN Y -month JUL Y.)

    • If a job should run every month except July, specify -month ALL Y and -month JUL N.

    • If a job is in a SMART folder and is scheduled according to the FIRSTDAY and SALARY1 Rule-Based Calendars, specify –RBC FIRSTDAY –RBC SALARY1.

  • The default for the -month parameter is ALL Y, which means that if you want to define a job that should run only in one specific month, you must first indicate that it should not run on any month. For example: -month ALL N -month NOV Y

  • An on parameter must be followed by at least one do parameter.

  • Additional post-processing conditions can be set by using -on <statement> <code>.

On statement: *

Code: RUNCOUNT>4

Do Shout: To: Control-M/EM

                  Text: "Job ran more than four times"

  • do parameters are dependent upon the last on parameter preceding them.

  • The order of parameters does not affect the outcome of the job, with the exception of on and do... parameters.

  • All fields of each parameter (as specified in the syntax section) must contain values. If no value is required for a parameter field, a null string "" must be specified in the relevant position in the parameter specification.

The -domail parameter has the following syntax:

-domail <destination> <cc> <severity> <subject> <message>

  • To specify this command without a value for the cc field, include a null string in the appropriate location.

-domail [email protected] "" R "subject line" "My message"

  • Normally, when a -dorerun parameter is implemented, the current run of the job ends with NOTOK status. To ensure that the job will have an OK status, even though it is rerun, specify a -dook parameter immediately after the -dorerun parameter.

  • The -dorerun parameter cannot be specified for a cyclic job.

  • When using doforcejob to force an entire folder, <job name> must be specified as a blank enclosed in quotation marks (that is, " ").

  • IN condition statements that use complex boolean logic can be specified.

  • For more information, see the description of the In Condition parameter in Control-M Parameters.

  • When ctmdefine is invoked from a script: To use the **** option for a incond date parameter, specify this parameter as "****"

-incond pk_oly_ok "****"

  • When the UNIX symbol ~ is used in a memlib, -override path, or -doclib parameter to represent the user’s home directory, the entire parameter should be enclosed in double quotation marks, which ensures that the ~ will be translated by the Agent before submission, and not by the Control-M/Server before transmission to the Agent computer.

-memlib "~/controlm/scripts/"

  • A maximum of 99 prerequisite conditions can be specified for docond parameters.

  • Condition names using both open and closed square brackets ([and]) must be enclosed in quotation marks (for example, "RATE[A1]").

  • The following special characters are disabled when they occur in prerequisite condition names:

    • ( open parenthesis

    • ) close parenthesis

    • | vertical bar

    • space

  • The -shift parameter has been extended to four characters (xyyy). The first character (x) indicates how to shift scheduling of the job if the original scheduling day of the job is not a working day in the CONFCAL calendar. Valid values are:

    • "" (Blank) – No shifting occurs. The job is not scheduled. Default.

    • > – Job scheduling is shifted to the next working day in the CONFCAL calendar. Additional shifting may be performed, depending on the yyy value, described below.

    • < – Job scheduling is shifted to the previous working day in the CONFCAL calendar. Additional shifting may or may not be performed, depending on the yyy value, described below.

    • @ – Tentatively schedule the job for the current day, even if the current day is not a working day in the CONFCAL calendar. Additional shifting may or may not be performed, depending on the yyy value, described below.

    The remaining three characters (yyy) shift scheduling of the job forward or backward the specified number of working days, as defined in the CONFCAL calendar. Valid values are:

    • Blank - no shifting occurs

    • -nn or +nn shifts the job forward or backward nn working days in the CONFCAL calendar. nn can be any value from 0 to 62.

  • If the result of shifting by yyy days is a day that is not allowed (-n was entered for that day in the DAYS parameter), the job is shifted to the next working day (for a forward shift), or to the previous working day (for a backward shift).

  • If the original scheduling day of the job is a working day in the CONFCAL calendar, the x value is ignored and the yyy value determines when the job is scheduled.

  • If the original scheduling day of the job is not a working day in the CONFCAL calendar, job scheduling is shifted according to the x value and then shifted again according to the yyy value (if specified) to determine when the job is scheduled.

  • If the original scheduling day of the job is not a working day in the CONFCAL calendar, and no value (blank) is specified for the x value, the job is not scheduled, and the yyy value (if specified) is ignored.

  • Confcal and Shift parameters are applied to a scheduling date only if that date already satisfies the Basic Scheduling criteria as specified in the Days, Months, Dates, and Weekdays parameters.

  • When a variable that ends with a backslash '\' is used with a ctmdefine command from a Control-M/Agent, it fails. For example, this can occur when a UNC path directory is used in a AFT job (%VARIABLE 'path\directory\'). Due to the way the Control-M/Agent submits the command to the Control-M/Server, it wraps it in double quotes, and when a backslash is used at the end of a variable, the quotes are ignored and cause it to fail. To avoid this, add a space character after the backslash.

For more information on the parameters for the ctmdefine utility, see ctmdefine Parameters.

ctmdefine Examples

The following command contains the minimum parameters required to define a job:

Copy
ctmdefine -folder cmmnds -jobname cmls13 \
-tasktype command  -sub_application em  -application test \
-date 0101  -cmdline "ls -l /etc/passwd"

You can get the same result by using the -input_file parameter as follows:

ctmdefine -input_file ~<controlm_owner>/ctm_server/data/ctmdefine_cmmnds.txt

The referenced file (ctmdefine_cmmnds.txt) contains the following lines:

Copy
-folder cmmnds
-jobname cmls13
-tasktype command 
-sub_application em 
-application test
-date 0101
-cmdline "ls -l \etc\passwd"

The following command includes examples of most of the parameters that be used to define a job:

Copy
ctmdefine -tasktype JOB -cyclic N\
-folder djsales -jobname dj102\
-description “Daily Summary"\
-sub_application SUPPLY -application SUPPLIES\
-file_path /users/ctm_server/ -file_name PROLYPAR -nodegrp UNIXGRP\
-run_as suppman\
-month ALL N\
-month MAR Y -month JUN Y -month SEP Y -month DEC Y\
-timeuntil 1800\
-priority AA -critical N\
-confirm Y\
-doclib /users/supply/doc/ -docmem prolypardoc\
-incond pk_oly_ok ODAT AND\
-incond pk_olp_ok ODAT AND\
-outcond pk_oly_ok ODAT DEL\
-outcond pk_olp_ok ODAT DEL\
-outcond pk_olypar ODAT ADD\
-variable %%PARM1 “%%CALCDATE %%ODATE -2"\
-quantitative tape 2 -quantitative cpu 50 \
-output MOVE /test/logs/\
-control disk2 E\
-shout OK oper2 U “Daily summary completed"\
-on “COPY JWINFO_2507” “%COPY-E-OPENIN, error"\
-dooutput MOVE /oper/openerr/\
-on “*” notok\
-dorerun\
-doshout em v “Daily summary failed. Attempting rerun"