Search code examples
unixhivesqoop

How to redirect the std errors from console to log file in shell script?


I'm trying to sqoop the data from RDBMS to Hive using sqoop-import command.

if the sqoop-import command fails when the corresponding table is missing in RDBMS. Then in the console, it throws standard error message

Table not found in Teradata.

I need to catch that type of errors and redirect that error message to a log file. How to do that?


Solution

  • Below two commands should do your work.

    sqoop import --connect....full command  2> error.log
    grep "Table not found in Teradata" error.log
    

    Explanation:-

    2> redirect error to log file named error.log

    match pattern in error.log