计划在Crontab上的配置单元查询 [英] To schedule a hive query on Crontab

查看:101
本文介绍了计划在Crontab上的配置单元查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮助我在Crontab中安排作业,该作业将在特定时间执行简单的Hive查询并以文本/日志文件的形式提供输出.

Can any one help me to schedule a job in Crontab which will execute a simple Hive query on specific time and provide me the output in text/log file.

我创建了一个批处理脚本来执行选择查询,但是在Crontab中执行它时出现错误(找不到Hive命令").但是,相同的脚本在外壳中运行良好.以下是我的脚本:

I have created a batch script to execute a select query , but getting error("Hive command not found") while executing it in Crontab. However same script is running fine through shell. Below is my script :

ip.sh
#!/bin/bash
echo "Starting of Job"
cd /home/hadoop/work/hive/bin
hive -e 'select * from mytest.empl'
echo "Script ends here"

Crontab: 10 * * * */home/hadoop/work/ip.sh >>/home/hadoop/work/quryout.log 2>& 1

Crontab: 10 * * * * /home/hadoop/work/ip.sh >> /home/hadoop/work/quryout.log 2>&1

执行Crontab之后,我在日志中得到以下消息:

After executing the Crontab , I am getting below message in log:

输出(Queryout.log): 开始工作 在第4行的ip.sh中找不到hive命令 脚本到此结束

Output(Queryout.log): Starting Of Job hive command not found in ip.sh at line number 4 Script ends here

推荐答案

在您的/home/hadoop/.bashrc中添加以下行:

export HIVE_HOME=/home/hadoop/work/hive
export PATH=$PATH:$HIVE_HOME/bin

现在,像这样更改脚本:

Now, change your script like this:

#!/bin/bash
echo "Starting of Job"
hive -e 'select * from mytest.empl'
echo "Script ends here"

这篇关于计划在Crontab上的配置单元查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆