定时将数据导入到hive中

应用crontab定时将数据导入到hive中:在调用/bin/hive -f 'loadData.sql' 的时候,报错:Cannot find hadoop installation: $HADOOP_HOME must be set or hadoop must be in the path。

查资料得知是由环境变量在crontab中不一定可识别引起的。于是在脚本中前面加入export HADOOP_HOME=/home/work/hadoop-0.20.2  问题解决。也可以加这句话/home/work/.bashrc

引用某博客的一句话:

crontab中必须十分注意环境变量的使用
#!/bin/sh并不是必须,只是当没有sha-bang的时候,也不要在第一行有"#"后带的中文注释!!
最好当然是加上sha-bang啦 #!/bin/sh

还有一个解决方案:
30 12 * * * source ~/.bashrc && shell.sh

猜你喜欢

转载自baiyunl.iteye.com/blog/964088