数据库
首页 > 数据库> > SHELL-收集Oracle已应用的PSU信息

SHELL-收集Oracle已应用的PSU信息

作者:互联网

 

1. 命令收集版本信息

# 创建数据收集脚本文件
OPER_FILE=${EXECUTE_ID}_oper.sh
if [[ "${OPER_USER}" = "${USER}" ]]; then
    echo "${PATCH_HOME}/opatch lsinventory > ${MODULE_OUT_DIR}/${OPER_USER}.info" > ${OPER_FILE}
else
    echo "su - ${OPER_USER} -c \"${PATCH_HOME}/opatch lsinventory\" > ${MODULE_OUT_DIR}/${OPER_USER}.info" >> ${OPER_FILE}
fi

sh -x ${OPER_FILE} &


 

2. 格式化输出

grep -E $'Patch +[0-9]+.*\nUnique Patch.*\nPatch description.*\nCreated on.*' ${MODULE_OUT_DIR}/${OPER_USER}.info | tr '\n' ' ' | sed -r 's/(Patch +[0-9]+ +:)/\n\1/g' | sed -r 's/Patch +([0-9]+) +: +applied +on +(.*) +Unique.*"(.*)" +Created +on +(.*)hrs +PST8PDT/\1##\4##\2##\3/g'

 

标签:OPER,SHELL,##,Patch,USER,FILE,Oracle,DIR,PSU
来源: https://www.cnblogs.com/wandering-mind/p/10793021.html