I have shell script that trigger Impala queries in CLI mode:

`impala-shell -i server -f query.sql`

How to capture the status of the Impala job into a log file, especially when it failed? And also, if it failed, automatically trigger the job to run it again?