Support Questions
Find answers, ask questions, and share your expertise
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

To schedule a hive query on Crontab


To schedule a hive query on Crontab

New Contributor

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 :


echo "Starting of Job"

cd /home/hadoop/work/hive/bin

hive -e 'select * from mytest.empl'

echo "Script ends here"



10 * * * * /home/hadoop/work/ >> /home/hadoop/work/quryout.log 2>&1


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



Starting Of Job

hive command not found in at line number 4

Script ends here



Re: To schedule a hive query on Crontab

Cloudera Employee

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'

Re: To schedule a hive query on Crontab

Rising Star



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 ?


Sathish (Satz)
Don't have an account?
Coming from Hortonworks? Activate your account here