使用 Coordinator job 能夠執行定時任務和時間觸發執行
須要注意的是 Oozie 默認使用的時區與中國時區不是一致的,須要進行一點修改html
<property> <name>oozie.processing.timezone</name> <value>GMT+0800</value> </property>
function getTimeZone() { Ext.state.Manager.setProvider(new Ext.state.CookieProvider()); return Ext.state.Manager.get("TimezoneId","GMT+0800"); }
nameNode=hdfs://cen-ubuntu.cenzhongman.com:8020 jobTracker=localhost:8032 queueName=default oozieAppsRoot=oozie-apps oozie.coord.application.path=${nameNode}/user/cen/${oozieAppsRoot}/cron-schedule start=2017-07-30T14:40+0800 end=2017-07-30T14:59+0800 workflowAppUri=${nameNode}/user/cen/${oozieAppsRoot}/cron-schedule
<workflow-app xmlns="uri:oozie:workflow:0.5" name="no-op-wf"> <start to="end"/> <end name="end"/> </workflow-app>
<coordinator-app name="cron-coord" frequency="0/1 * * * *" start="${start}" end="${end}" timezone="GMT+0800" xmlns="uri:oozie:coordinator:0.4"> <action> <workflow> <app-path>${workflowAppUri}</app-path> <configuration> <property> <name>jobTracker</name> <value>${jobTracker}</value> </property> <property> <name>nameNode</name> <value>${nameNode}</value> </property> <property> <name>queueName</name> <value>${queueName}</value> </property> </configuration> </workflow> </action> </coordinator-app>
export OOZIE_URL=http://cen-ubuntu:11000/oozie/ bin/oozie job --config oozie-apps/cron-schedule/job.properties -run
EL Constant | Value | Example |
---|---|---|
${coord:minutes(int n)} | n | ${coord:minutes(45)} --> 45 |
${coord:hours(int n)} | n * 60 | ${coord:hours(3)} --> 180 |
${coord:days(int n)} | variable | ${coord:days(2)} --> minutes in 2 full days from the current date |
${coord:months(int n)} | variable | ${coord:months(1)} --> minutes in a 1 full month from the current date |
${cron syntax} | variable | ${0,10 15 * * 2-6} --> a job that runs every weekday at 3:00pm and 3:10pm UTC time |
Crontab使用參考ubuntu
Field name | Allowed Values | Allowed Special Characters |
---|---|---|
Minutes | 0-59 | , - * / |
Hours | 0-23 | , - * / |
Day-of-month | 1-31 | , - * ? / L W |
Month | 1-12 or JAN-DEC | , - * / |
Day-of-Week | 1-7 or SUN-SAT | , - * ? / L # |
Exampletomcat
Cron Expression | Meaning |
---|---|
10 9 * * * | Runs everyday at 9:10am |
10,30,45 9 * * * | Runs everyday at 9:10am, 9:30am, and 9:45am |
0 * 30 JAN 2-6 | Runs at 0 minute of every hour on weekdays and 30th of January |
0/20 9-17 * * 2-5 | Runs every Mon, Tue, Wed, and Thurs at minutes 0, 20, 40 from 9am to 5pm |
1 2 L-3 * * | Runs every third-to-last day of month at 2:01am |
1 2 6W 3 ? | Runs on the nearest weekday to March, 6th every year at 2:01am |
1 2 * 3 3#2 | Runs every second Tuesday of March at 2:01am every year |
0 10,13 * * MON-FRI | Runs every weekday at 10am and 1pm |
解決:關閉頻率檢查功能 配置oozie-site.xml文件app
<property> <name>oozie.service.coord.check.maximum.frequency</name> <value>false</value> </property>