1. 使用JIL创建JOB
Syntax:
sub_command: job_name
attribute_keyword: value
注:
- 指定box的时候, 需要预先定义好该box
- 属性值带有冒号时, 应该是用转义字符\, 如10:00 --> 10\:00
关于备注:
有2中备注方式:
- 行备注, 采用#开始的整行
- 多行备注, 类似C语言, /* xxxx */
sub_command包含
- insert_job:增加一个新job
- insert_machine:增加一个新machine
- update_job:更新已存在的job
- delete_job:从数据库删除job
- delete_box:删除存在的box,包括所有在box里的job
- override_job:覆盖job属性,下次运行时生效
采用jil命令运行jil脚本文件:
jil < test.jil
job由许多不同属性构成, 最重要的三点:when, where, if
- when
指定开始时间,星期, 日历,watched file
- where
机器名, 指运行该job的机器
- if
运行条件, SUCCESS
例:
(1). 创建 Command Jobs
/* ----------------- XXXX_TES_RECON ----------------- */ insert_job: XXXX_TES_RECON job_type: c box_name: SG_TES_DATA_BX command: $SG_BIN_DIR/recon_dt.sh PAPRO SG machine: SG_TES_VM permission: gx,mx,me date_conditions: 1 days_of_week: tu, we, th, fr, sa start_times: "05:00" condition: s(SG_TES_DATA_ROFILE) description: "genertate recon for ROFILE" std_out_file: $SG_TES_LOG_DIR/Autosys/$AUTO_JOB_NAME.out std_err_file: $SG_TES_LOG_DIR/Autosys/$AUTO_JOB_NAME.err alarm_if_fail: 1 profile: /app/TES/SG/config/autosys.profile
这个脚本将创建名为:XXXX_TES_RECON的job
运行时间: 每周二 -- 周六 05:00启动,依赖条件 SG_TES_DATA_ROFILE SUCCESS
运行的机器:SG_TES_VM
job 类型:command
shell :$SG_BIN_DIR/recon_dt.sh PAPRO SG
box:SG_TES_DATA_BX
(2). 创建 File Watcher Jobs
/* ----------------- XXXX_TES_UPD_LIST_WATCHER ----------------- */ insert_job: XXXX_TES_UPD_LIST_WATCHER job_type: f box_name: XXXX_TES_ID_BX machine: HK_TES_VM permission: gx,mx,me description: "File watcher for EEW data (UpdateList.csv)" term_run_time: 120 watch_file: $SG_TES_INPUT_DIR/UpdateList.csv watch_interval: 60 alarm_if_fail: 1 profile: /app/TES/SG/config/autosys.profile
job名:XXXX_TES_UPD_LIST_WATCHER
运行条件: 每个60秒监控$SG_TES_INPUT_DIR/UpdateList.csv
运行的机器:HK_TES_VM
job 类型:f
box:XXXX_TES_ID_BX
(3). Box Jobs
/* ----------------- XXXX_TES_ID_BX ----------------- */ insert_job: XXXX_TES_ID_BX job_type: b permission: gx,mx,me date_conditions: 1 days_of_week: mo, tu, we, th, fr start_times: "22:30" condition: s(XXXX_DDD) description: "EOD job for update auth" alarm_if_fail: 1
job名:XXXX_TES_ID_BX
运行时间: 每周一 -- 周五 22:30启动,依赖条件 XXXX_DDD
job 类型:b
添加machine
machine类型包括:
■ Real machine -->r
■ Virtual machine -->v
■ Windows -->n
■ NSM -->t
■ Universal Job Management Agent -->t
■ Unicenter AutoSys JM Connect -->c
默认n或者v
例子:
insert_machine: (machine_name bocovic)
Type: t
更新job
update_job: EOD_post
condition: NULL
box_name: EOD_box
设置时间依赖
update_job: test_run
date_conditions: y
days_of_week: mo, we, fr
start_times: 10:00, 14:00
设置时区
timezone: IST-5:30
删除job
delete_job: test_run
删除job box
delete_box: EOD_box
如果需要保留box里面的job:
delete_job: EOD_box
job属性:
- auto_hold
- min_run_alarm
- std_in_file
- command
- n_retrys
- std_out_file
- condition
- profile
- term_run_time
- date_conditions
- run_calendar
- watch_file
- days_of_week
- run_window
- watch_file_min_size
- exclude_calendar
- start_mins
- watch_interval
- machine
- start_times
- max_run_alarm
- std_err_file
2. Job 状态
Status | Description |
INACTIVE | JOB 未运行 |
STARTING | JOB初始化中 |
RUNNING | JOB运行中 |
SUCCESS | JOB运行成功 |
FAILURE | JOB运行失败 |
TERMINATED | JOB 在running时被kill |
RESTART | 其它硬件或者应用问题导致的job需要被重启 |
QUE_WAIT | job达到启动条件,但由于其它原因导致暂时无法启动时的状态 |
ACTIVATED | 适用于box job, 指box已经在RUNNING,但是job还未能启动 |
ON_HOLD | job被设置ON_HOLD, 只有收到JOB_OFF_HOLD命令时才能运行 |
ON_ICE | job被设置ON_ICE, 只有收到JOB_OFF_ICE命令时才能恢复运行 |
3. autosys常用命令
查看job信息->
(1). autorep
命令格式:
autorep {-J job_name | -M machine_name | -G global_name} [-s | -d | -q | -o over_num | -u] [-r run_num][-L print_level][-t] [-D data_server:database | -D TNSname]
- -J job_name job name支持模糊查询,如:%box%
- -M machine_name 查询machine信息
- -G global_name
- -s job综合报告信息(默认)
- -d 详细信息
- -q 查询job,机器jil定义
例子:
查询以HKSG开头的所有job:
autorep -J HKSG%
查询job的定义:
autorep -J HKSG_TES_ID_BX -q
查询machine:
autorep -M HK_TES_VM
(2). Send Events命令
sendevent -E event [-S autoserv_instance] [-A alarm] [-J job_name][-s status] [-C comment] [-P priority] [-M max_send_trys][-q job_queue_priority] [-T "time_of_event"][-G "global_name=value"] [-k signal_numbers] [-u]
- -E event
- -J job_name
- -s status
例子:
启动job名为job_sales:
sendevent -J job_sales -E STARTJOB
强制启动job_daily:
sendevent -J job_daily -E FORCE_STARTJOB -C "wanted to leave early,forced it"
cancel 未运行的job:rundata
sendevent -E JOB_OFF_HOLD -J rundata -u
更新job XXXX_TES_EOD_BX 的状态为SUCCESS:
sendevent -E CHANGE_STATUS -J XXXX_TES_EOD_BX -s SUCCESS
kill job:
sendevent -E KILLJOB -J XX_TES_RECON
设置job:ON ICE
sendevent -E JOB_ON_ICE -J XX_TES_EOD_BX
设置job:OFF ICE
sendevent -E JOB_OFF_ICE -J XX_TES_EOD_BX