1
votes

I am not able to execute hadoop/hive commands from Crontab. Basically i have scheduled a perl script in crontab which contains system commands which are setting PATH before my operations.

I am aware that, the env of running from cron could be different from your regular shell. That's the reason i am setting paths like below. IS there any other way to make it work?

system(". /home/ciber/.bash_profile");

system("export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64");

system("export HADOOP_INSTALL=~/poc/install/hadoop-1.0.3");

system("export PATH=$PATH:$HADOOP_INSTALL/bin");

system("export HADOOP_HOME=$HADOOP_INSTALL");

system("export HIVE_INSTALL=~/poc/install/hive-0.9.0");

system("export PATH=$PATH:$HIVE_INSTALL/bin");

@Jingguo Yao: Do you have any idea abt this?

2

2 Answers

0
votes

You can absolute path of commands in crontab . Also, you can declare env variable in crontab simply . for example foo=bar

0
votes

If it is executing properly from terminal and not in crontab, loading user bash profile in the script should do the work, as below

. ~/.bash_profile

or

. /home/<user>/.bash_profile

Usually #!/bin/bash is included in bash_profile and it will have user specific configurations as well.