Thursday, October 25, 2012

autosys

Autosys Jobs There are three types of jobs, - Command Jobs : execute commands - File watcher Jobs: watch for the arrival of a specified file. - Box Jobs: are containers that hold other jobs (including other boxes). A box job can be used to organize and control process flow. The box itself performs no actions, although it can trigger other jobs to run. An important feature of this type of job is that boxes can be put inside of other boxes. Autosys Job Status Autosys keeps track of the current status of every job. Following are the statuses – INACTIVE (IN) - The job has not yet been processed. Either the job has never been run, or its status was intentionally altered to “turn off” its previous completion status. ACTIVATED (AC) - The top-level box job is in RUNNING state, but the job itself has not started yet. STARTING (ST) - The event processor has initiated the start job procedure with the Remote Agent. RUNNING (RU) - The job is executing. If the job is a box job, this value simply means that the jobs within the box may be started (other conditions permitting). If it is a command or file watcher job, the value means that the process is actually running on the remote machine. SUCCESS (SU) - The job exited with an exit code equal to or less than the “maximum exit code for success.” By default, only the exit code “0” is interpreted as “success.” FAILURE (FA) - Job exited with an exit code greater than “maximum exit code for success.” Any number greater than zero is interpreted as “failure.” Autosys issues an alarm if a job fails. TERMINATED (TE) - The job terminated while in the RUNNING state. A job can be terminated if a user sends a KILLJOB event or if it was defined to terminate if the box it is in failed. A job may also be terminated if it has exceeded the maximum run time or if it was killed from command line through UNIX kill command. Autosys issues an alarm if a job is terminated. RESTART (RE) - Job was unable to start due to hardware or application problems, and has been scheduled to restart. QUE-WAIT (QU) - The job can logically run (that is, all the starting conditions have been met), but there are not enough machine resources available. ON_HOLD (OH) - This job is on hold and will not be run until it receives the JOB_OFF_HOLD event. ON_ICE (OI) - This job is removed from all conditions and logic, but is still defined to Autosys. Operationally, this condition is like deactivating the job. It will remain on ice until it receives the JOB_OFF_ICE event. Default Box Job behaviour Some important rules to remember about boxes are: - Jobs run only once per box execution. - Jobs in a box will start only if the box itself is running. - As long as any job in a box is running, the box remains in RUNNING state; the box cannot complete until all jobs have run. - By default, a box will return a status of SUCCESS only when all the jobs in the box have run and the status of all the jobs is "success”. - By default, a box will return a status of FAILURE only when all jobs in the box have run and the status of one or more of the jobs is "failure." - Unless otherwise specified, a box will run indefinitely until it reaches a status of SUCCESS or FAILURE. - Changing the state of a box to INACTIVE (via the sendevent command) changes the state of all the jobs in the box to INACTIVE. Defining Jobs There are the two methods you can use to create job definitions: - Using the Autosys Graphical User Interface (GUI). - Using the Autosys Job Information Language (JIL) through a command-line interface. What is difference between ‘ON HOLD’ and ‘ON ICE’ status? The difference between "on hold" and "on ice" is that when an "on hold" job is taken off hold, if its starting conditions are already satisfied, it will be scheduled to run, and it will run. On the other hand, if an "on ice" job is taken "off ice," it will not start, even if its starting conditions are already satisfied. This job will not run until its starting conditions reoccur. The other major distinction is that downstream jobs from the job which is "on ice" will run as though the job succeeded. Whereas, all dependent jobs do not run when a job is on "on hold”. What are different starting conditions for Autosys job? Autosys determines whether to start or not to start a job based on the evaluation of the starting conditions (or starting parameters) defined for the job. These conditions can be one or more of the following: - Date and time scheduling parameters are met (it is or has passed the specified date and time). - Starting Conditions specified in the job definition evaluate to true. - For jobs in a box, the box must be in the RUNNING state. - The current status of the job is not ON_HOLD or ON_ICE. Every time an event changes any of the above conditions, Autosys finds all the jobs that may be affected by this change, and determines whether or not to start them. Sample jil code / Writing jil code insert_job: template job_type: c box_name: box1 command: ls -l machine: localhost owner: lyota01@TANT-A01 permission: gx,ge,wx,we,mx,me date_conditions: 1 days_of_week: all start_times: “15:00, 14:00″ run_window: “14:00 - 6:00″ condition: s (job1) description: “description field” n_retrys: 12 term_run_time: 60 box_terminator: 1 job_terminator: 1 std_out_file: /tmp/std_out std_err_file: /tmp/std_err min_run_alarm: 5 max_run_alarm: 10 alarm_if_fail: 1 profile: /tmp/.profile Explanation of each line: Insert_job: this will let the Autosys server to recognize the job and inserts into Autosys DataBase. Jobtype: there are two types of jobs namely box and child ( c=child, b=box) box_name: this is the box job name: box job can have more than 1 child jobs. commands: this is where you tell Autosys, what to do when the job runs. machine: name of the machine where you want to run the job. owner: owner of the job. permissions: date_conditions: 1 if you have any specifications. days_of_week: on which days of the week you want the job to run. start_time: the time at which the job should kick-off. run_window: this option is for monitoring jobs. Job will run continuously for specified time window. conditions: You can specify the dependencies. like success of some other job. description: n_retrys: no of retrys on a failure. term_run_job: the job will terminate if it runs for specified time. box_terminator: if 1, terminates box job depends on term_run_time. job_terminator: if 1, terminates child job depends on term_run_time. std_out_file: standard output file (log) for the job std_err_file: Error log file if the job fails min_run_alarm: if the job terminates/completed within that time it generate an alarm max_run_alarm: if the job runs for more than the specified time, it generate an alarm alarm_if_fail: generates an alarm if the job fails profile: the file where you can keep all your variables (variable names) We don’t use all the above options in all the jobs, it depends on the requirements. Here is a sample job which will verify a particular process is running or not. /* —————– SAP_UAT_MU03_C —————– */ insert_job: SAP_UAT_MU03_C job_type: c command: /local/SAP/processCheckUAT.sh machine: MU03-UAT owner: admin@MU03-UAT permission: gx,wx,mx,me days_of_week: all start_times: “15:00, 14:00″ description: “Job used for Run testing of process” alarm_if_fail: 1 max_exit_success: 1 To Insert a new Autosys job as JIL code issue command "jil" bash-3.00$ jil >>1> "The following prompt will appear" copy paste the jil code u have made example of jil code below. At the end the "C" or "B" determines if the job is box job or child job. If the jil is inserted properly, then successful message will come and exit; else it will show error. For Example - · Insert Box using JIL jil jil>>01> insert_job: box_TG_cafe job_type: b jil>>02> owner: autosys jil>>03> permission: gx,wx,mx jil>>04> date_conditions: 1 jil>>05> days_of_week: sa jil>>06> start_times: "16:00" jil>>07> condition: s(box_TG_post_dp_batch) jil>>08> description: "CAFE Extract" jil>>09> alarm_if_fail: 0 jil>>10> group: TG_cafe jil>>11> exit ___________________________________________________________________ CAUAJM_I_50204 Inserting/Updating Job: box_TG_cafe CAUAJM_I_10122 Job 'box_TG_cafe' scheduled: 01/07/2012 16:00:00 CAUAJM_I_50205 Database Change WAS Successful! __________________________________________________________________ · Insert Command using JIL jil jil>>01> insert_job: job_TG_extract_customer_premise_info job_type: c jil>>02> box_name: box_TG_cafe jil>>03> command: sudo -u energyop –i $${CISSOURCE}/CAFE/extract_cust_premise_info.sh jil>>04> machine: TGDB jil>>05> owner: autosys jil>>06> permission: gw,gx jil>>07> condition: s(job_customer_enroll_info) jil>>08> description: "extract_customer_premise_info" jil>>09> std_out_file: $${CISAUTOLOGS}/extract_customer_premise_info_out.log jil>>10> std_err_file: $${CISAUTOLOGS}/extract_customer_premise_info_err.log jil>>11> alarm_if_fail: 0 jil>>12> group: TG_cafe jil>>13> exit ____________________________________________________________________ CAUAJM_I_50204 Inserting/Updating Job: job_TG_extract_customer_premise_info CAUAJM_I_50205 Database Change WAS Successful! ____________________________________________________________________ · Insert File Watcher using JIL jil jil>>01> insert_job: fw_TG_CW27505_Extract_Premise job_type: f jil>>02> box_name: box_TG_cafe jil>>03> machine: TGFTP jil>>04> owner: energyop jil>>05> permission: gw, gx jil>>06> condition: s(job_TG_extract_customer_premise_info) jil>>07> description: "CW27505_Extract_Premise_yyyy-mm-dd.dat.gz file watcher" jil>>08> watch_file: $${CISFTPFTP}/CAFE/out/CW27505_Extract_Premise_$${DATEA}.dat.gz jil>>09> watch_interval: 60 jil>>10> alarm_if_fail: 0 jil>>11> group: TG_cafe jil>>12> exit ________________________________________________________________ CAUAJM_I_50204 Inserting/Updating Job: fw_TG_CW27505_Extract_Premise CAUAJM_I_50205 Database Change WAS Successful! ________________________________________________________________ Autosys Command - Autorep The command reports information about a job status and also job defination. It also reports information about job overrides and global variables. Syntax : autorep (-J job_name /-M machine_name /-G global_name) [-s -d -q -o over_num] [-r run_num] To display a status of Autosys job. autorep -J (job name here) Viewing JIL code for any Autosys job autorep –q -J (job name here) To obtain the information of previous runs autorep -J (job name here) -r (No of runs back) Autosys Command - sendevent This command send events to Autosys for a variety of purposes, including starting or stopping autosys jobs, stopping the Event processor, and putting a job on hold. This command is also used to set autosys global variables or cancel a scheduled event. Following are the example of sendevent command frequently used. sendevent -E FORCE_STARTJOB -j sendevent -E STARTJOB -j sendevent -E JOB_ON_HOLD -j : Job now on hold sendevent -E JOB_OFF_HOLD -j : Job now released. sendevent -E CHANGE_STATUS -s SUCCESS -j : Job status changed to success sendevent -E JOB_ON_ICE -j : Job now "on ice" sendevent -E JOB_OFF_ICE -j : Job taken off "ice". Beware of dependancies!! sendevent -E KILLJOB -j : Job "Killed" sendevent -e CHANGE_STATUS -s INACTIVE -j sendevent –E STOP_DEMON : Shutdown autosys sendevent –E SET_GLOBAL –G “var_name=/home/dinesh” : To set variable in autosys sendevent is normally used with "-E" & -J option -J job_name : Specifies name of the job to event should be sent. This option is required for all events except STOP_DEMON, COMMENT, ALARM, or SET_GLOBAL -E event: Specifies the any one of following events to be sent. STARTJOB KILLJOB DELETEJOB FORCE_STARTJOB JOB_ON_ICE JOB_OFF_ICE JOB_ON_HOLD JOB_OFF_HOLD CHANGE_STATUS STOP_DEMON CHANGE_PRIORITY COMMENT ALARM SET_GLOBAL SEND_SIGNAL Other Autosys Commands # Reports the current status of a specific job, or the value of an Autosys global variable. autostatus -J job_name [-S instance] #To see job report autorep –w –j # To find dependent downstream jobs and their status. job_depends –c –w –j # Load autosys JIL file jil < JIL_source # Find unique commands currently being used autorep -J PARTIALJOBNAME% -q | grep "command:" | awk -F: '{print $2}'| awk '{print $1}' | sort -u > /tmp/cmds.txt # Forecast report from date to infinity: job_depends -t -J ALL -F "mm/dd/yyyy" # Display all jobs scheduled to run between these two dates: job_depends -t -J ALL -F:06/01/2008 -T:06/30/2008 # check if the event processor is up and running chk_auto_up # Display list of available time zones: autotimezone -l # Get version information autoflags -a # View Remote Agent log autosyslog -J jobname # To start autosys GUI panel autosc & # Verify both client & server are correctly configured autoping -m machine_name # To convert jobs from crontab to autosys jobs. Below command will create a file1.jil in present directory. cron2jil –f file1 #Prints, adds & deletes custom calendar definations autocal_asc # To change, edit, exec superusers, change DB passwds, change remote authentication method autosys_secure [COURTESY - All helping hands and helpful websites on internet.]

No comments:

Post a Comment