使用的 Oozie 命令
oozie jobs -oozie http://localhost:11000/oozie -localtime | grep "2013-05-08" > Input.txt
Oozie 日志(Input.txt)
61-oozie DProSUCCEEDED chronicles users 2013-05-08 04:47 2013-05-08 04:53
61-oozie DPRUNNING chronicles users 2013-05-08 04:47
61-oozie DProcessSuspended chronicles users 2013-05-08 04:42 2013-05-08 04:48
61-oozie DKILLED chronicles users 2013-05-08 04:07 2013-05-08 04:09
我想要一个额外的列作为“状态”,它将状态消息存储为“SUCCESS/RUNNING/KILLED/SUSPENDED/Prep”。
我们将从第二列获取“Status”消息作为<(processname)><(Status)>。
我无法从上面的文本中猜出分隔符。因此我们可以利用 AWK/cut/substring 概念。
Status messages are static . Job names are dynamic.
将会有 4 条状态消息。
- 成功
- 正在运行
- 准备
- 杀了
- 暂停
期望的输出
61-oozie DPro chronicles users 2013-05-08 04:47 2013-05-08 04:53 SUCCEEDED
61-oozie DP chronicles users 2013-05-08 04:47 - RUNNING
61-oozie DProcess chronicles users 2013-05-08 04:42 2013-05-08 04:48 Suspended
61-oozie D chronicles users 2013-05-08 04:07 2013-05-08 04:09 KILLED
最佳答案
提取所需的状态并将其放在行尾,
perl -pe 's/\B(succeeded|running|suspended|killed|prep)//i and $w=$1 and s/$/ $w/' file
关于perl - Oozie 日志上的模式匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16438423/