如果python脚本在获得异常时返回非零错误级别,则可以使用|| {}记录消息。
./scriptA.py '$file' || {
printf 'npythonscriptscripta.pyfailedwithfile' % s'. n ' $ file ' shell testlog.txt
}
我其实是想先简化你的代码:
#! /zxdbz/bash
yesterday=$ (date-- date ' yesterday ' ' % y % m % d ' ) )
f today=$ (date-- date ' today ' ' % m-% d-% y ' )
year=$(date ' %Y ' )
readarray-t文件列表
for file in '${filesList[@]}; 德奥
printf 'nstartprocessingfile 3360 % sn ' ' $ file ' shell testlog.txt
./scriptA.py '$file' || {
printf 'npythonscriptscripta.pyfailedwithfile' % s'. n ' $ file ' shell testlog.txt
}
printf 'nendprocessingfile 3360 % sn ' ' $ file ' shell testlog.txt
道恩