Reply
New Contributor
Posts: 1
Registered: ‎05-28-2015

To schedule a hive query on Crontab

Hi ,

 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.

 

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

 

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

 

Output(Queryout.log):

Starting Of Job

hive command not found in ip.sh at line number 4

Script ends here

 

Highlighted
Cloudera Employee
Posts: 16
Registered: ‎01-27-2015

Re: To schedule a hive query on Crontab

You need to use ./hive in order to execute a command from the directory you are positioned:

 

cd /home/hadoop/work/hive/bin

./hive -e 'select * from mytest.empl'

Contributor
Posts: 47
Registered: ‎09-12-2014

Re: To schedule a hive query on Crontab

[ Edited ]

Hi,

 

Make sure that the hive command is available at all paths, (i.e) hive's bin directory exported to shell varialbes.

 

Are you starting the hive shell normally or starting shell under hive's bin directory ?

 

Thanks,
Sathish (Satz)