Please explain me the following code how it will work
${SCRIPTS_DIR}user_info >${log_dir}${BASE_JOB_NAME}.log 2>&1
Please explain me the following code how it will work
${SCRIPTS_DIR}user_info >${log_dir}${BASE_JOB_NAME}.log 2>&1
First of all variables ${SCRIPTS_DIR}, ${log_dir}, ${BASE_JOB_NAME} are expanded.
Then script ${SCRIPTS_DIR}user_info will be executed, it's stdout and stderr will be redirected to ${log_dir}${BASE_JOB_NAME}.log
That is ok but what is the meaning of 2>&1
redirect stderr (handler=2) to stdout (handler=1)
You can read the command
>logfile 2>&1
as (nothing means stdout by default)
stdout=logfile stderr=stdin
So everything from stdout and stderr will be written to logfile