我已经创建了以下函数,当我使用shell脚本执行此函数时,它可以正常运行,但不执行后续步骤
time_check()
{
. /u01/scripts/${1}.env
export create_env_log=${logs}/create_env_log_${dts}.log
echo 'STime:' date +%s > ${create_env_log}
"$@"
echo 'ETime:' date +%s >> ${create_env_log}
export st_time= grep -i STime ${create_env_log} |cut -d':' -f2
export en_time= grep -i ETime ${create_env_log} |cut -d':' -f2
export exectime=$((en_time-st_time))
echo 'Completed in ' printf '%dd:%dh:%dm:%ds\n' $(($exectime/86400)) $(($exectime%86400/3600)) $(($exectime%3600/60)) $(($exectime%60)) >> ${create_env_log}
Totexectime=$((Totexectime+exectime))
echo 'This step completed in : 'printf '%dd:%dh:%dm:%ds\n' $(($exectime/86400)) $(($exectime%86400/3600)) $(($exectime%3600/60)) $(($exectime%60))
}
在我的shell脚本中,我将以下行放置:
time_check /u01/scripts/copy.sh ${1} | tee ${copylog}
echo "Starting Next Steps now:" >>> Issue here , not coming to this phase.
我得到这样的输出:
此步骤完成:0d:0h:12m:9s(这是time_check /u01/scripts/copy.sh的输出)