在合成孔径雷达(SAR)数据处理中,批量执行多个任务并记录日志 是一个常见需求。这个 Bash 脚本 可以自动执行 run_01 到 run_16 的 InSAR 处理任务,并分别为每个任务创建日志文件,方便后续调试和分析。
当然这是单个文件单个运行哈 ,就是不用一直用手点啦
#!/bin/bash
runfiles_path="/mnt/e/insar_order_test/Stacks/run_files"
log_dir="/mnt/e/insar_order_test/logs"
mkdir -p "$log_dir"
for file in $(ls $runfiles_path/run_??_* 2>/dev/null | sort); do
log_file="$log_dir/$(basename "$file").log"
echo "=============================================" | tee -a "$log_file"
echo "Executing: $file" | tee -a "$log_file"
echo "======= Contents of $file =======" | tee -a "$log_file"
cat "$file" 2>/dev/null | tee -a "$log_file"
echo "=============================================" | tee -a "$log_file"
bash "$file" | tee -a "$log_file"
echo "✅ Execution of $file completed!" | tee -a "$log_file"
done
echo "✅ 所有任务已按顺序执行完成!" | tee -a "$log_dir/run_all.log"
自动遍历 run_01 ~ run_16 并执行
为每个 run_xx_* 任务生成单独的日志文件
在终端显示执行过程,同时保存到日志
最终汇总所有任务的执行情况到 run_all.log