如何按顺序从 shell 脚本调用 Pig 脚本
how to call Pig scripts from shell script sequentially
我在一个文件中有 Pig 脚本序列,我想从 Shell 脚本中执行它
它执行 pig 脚本 sqeuenciatly。
例如:
sh script.sh /it/provider/file_name PIGddl.txt
假设 PIGddl.txt 有像
这样的 Pig 脚本
- 记录数
- 无效验证 e.t.c
如果所有 Pig 查询都在一个文件中,那么如何从 Shell 个脚本执行 pig 脚本?
我还没有对此进行测试,但我很确定它会正常工作。
假设您有两个想要使用 shell 脚本 运行 的 pig 文件,那么您将使用以下内容编写一个 shell 脚本文件:
#!/bin/bash
pig
exec pig_script_file1.pig
exec pig_script_file2.pig
所以当你 运行 这个 shell 脚本时,最初它会执行 pig
命令然后进入 grunt shell
然后它会按顺序执行你的 pig 文件你提到的
更新:
The above solution doesn't work. Please refer the below one which is
tested
使用以下内容更新您的脚本文件,以便它可以 运行 您的 pig 文件按照您定义的顺序
#!/bin/bash
pig pig_script_file1.pig
pig pig_script_file2.pig
下面的想法可行,但是如果你想要顺序过程,比如如果 1 执行然后执行 2 否则执行 3 种流程,你可以使用 Oozie 来 运行 并安排作业。
#!/bin/sh
x=1
while [ $x -le 3 ]
do
echo "pig_dcnt$x.pig will be run"
pig -f /home/Scripts/PigScripts/pig_dcnt$x.pig --param timestamp=$timestamp1
x=$(( $x + 1 ))
done
这是你必须做的
1. 将 xxx.pig 文件保存在某个位置 #
2. 从 shell 执行这个 pig 脚本使用下面的命令
pig -p xx=date(如果你有一些参数要传递)-p xyz=value(如果有另一个参数要传递)-f /path/xxx.pig
-f 用于执行 .pig 文件中的 pig 代码行。
我在一个文件中有 Pig 脚本序列,我想从 Shell 脚本中执行它 它执行 pig 脚本 sqeuenciatly。
例如:
sh script.sh /it/provider/file_name PIGddl.txt
假设 PIGddl.txt 有像
这样的 Pig 脚本- 记录数
- 无效验证 e.t.c
如果所有 Pig 查询都在一个文件中,那么如何从 Shell 个脚本执行 pig 脚本?
我还没有对此进行测试,但我很确定它会正常工作。
假设您有两个想要使用 shell 脚本 运行 的 pig 文件,那么您将使用以下内容编写一个 shell 脚本文件:
#!/bin/bash
pig
exec pig_script_file1.pig
exec pig_script_file2.pig
所以当你 运行 这个 shell 脚本时,最初它会执行 pig
命令然后进入 grunt shell
然后它会按顺序执行你的 pig 文件你提到的
更新:
The above solution doesn't work. Please refer the below one which is tested
使用以下内容更新您的脚本文件,以便它可以 运行 您的 pig 文件按照您定义的顺序
#!/bin/bash
pig pig_script_file1.pig
pig pig_script_file2.pig
下面的想法可行,但是如果你想要顺序过程,比如如果 1 执行然后执行 2 否则执行 3 种流程,你可以使用 Oozie 来 运行 并安排作业。
#!/bin/sh
x=1
while [ $x -le 3 ]
do
echo "pig_dcnt$x.pig will be run"
pig -f /home/Scripts/PigScripts/pig_dcnt$x.pig --param timestamp=$timestamp1
x=$(( $x + 1 ))
done
这是你必须做的 1. 将 xxx.pig 文件保存在某个位置 # 2. 从 shell 执行这个 pig 脚本使用下面的命令 pig -p xx=date(如果你有一些参数要传递)-p xyz=value(如果有另一个参数要传递)-f /path/xxx.pig -f 用于执行 .pig 文件中的 pig 代码行。