我正在尝试通过在sascommand完成后在sasbatch脚本中实现一些代码来创建自动重运行机制。总体思路是:
找到sas进程的日志和包含当前作业的流的ID,
检查日志中是否包含特定的ORA-xxxxx错误,我们知道针对它们的解决方案只是重新运行该过程,
如果是这样,则从LSF平台命令行界面触发jrerun类,
退出sasbatch将$ rc传递给LSF
该想法的实现为:
#define used paths
log_dir=/path/to/sas_logs_directory
out_log=/path/to/auto-rerun_log.txt
out_log2=/path/to/lsf_rerun_log.txt
if [ -n "${LSB_JOBNAME}"]; then
if [ ! -f "$out_log"]; then
touch $out_log
fi
#get flow runtime attributes
IFS-: read -r flow_id username flow_name job_name <<< "${LSB_JOBNAME}"
#find log of the current process
log_path=$(ls -t $log_dir/*.log | xargs grep -li "job:\s*$job_name" | grep -i "/$flow_name_" | head -1)
#set path to txt file containing lines which represents ORA errors we look for
conf_path-/path/to/error_list
#analyse process' log line by line
while read -r line;
do
#if error is found in log then try to rerun flow
if grep -q "$line" $log_path; then
(nohup /path/to/rerun_script.sh $flow_id >$out_log2 2>&1) &
disown
break
fi
done < $conf_path
fi
虽然rerun_script是在睡眠命令后调用jrerun类的脚本-为了同时允许父脚本退出$ rc。看起来像:
sleep 10
/some/lsf/path/jrerun
问题是作业一直在运行。在LSF历史记录中,我可以看到在作业退出之前调用了jrerun。此外,在$ out_log2中,我可以看到消息:<flow_id> has no starting or exit points.
有人知道在jrerun调用之前如何将返回码传递给LSF吗?还是在Platform LSF中执行SAS作业自动重运行的更简单方法?
我正在使用SAS 9.4和Platform Process Manager 9.1
或者也许是在Platform LSF中执行SAS作业自动重运行的更简单方法?
我不了解SAS部分。但是在LSF方面,至少有两种方法可以重新安排工作。
如果可以控制作业脚本,则可以使用特殊的流程退出值来自动重新排队作业。
https://www.ibm.com/support/knowledgecenter/en/SSWRJV_10.1.0/lsf_admin/job_requeue_about.html
如果您在作业脚本之外具有控制权,则可以使用brequeue -r
重新排队正在运行的作业。
https://www.ibm.com/support/knowledgecenter/en/SSWRJV_10.1.0/lsf_command_ref/brequeue.1.html
祝你好运
我设法通过使用另外两个配置文件来使它正常工作。当我的grep
返回1时,我将找到的flow_id
添加到flow_list.txt
配置文件中,并特别修改了trigger_file.txt
。
我在LSF中计划了附加流execute_rerun
,在文件trigger_file.txt
被修改后触发。 execute_rerun
流逐行读取flow_list.txt
配置文件,并在每个流上调用jrerun
方法。
我设法实现了流程的自动重新运行,由于某些错误,该流程失败了。