

目标 实现记录SHELL执行的开始时间,结束时间,运行状态,错误信息等,以函数封装日志记录的方式,脚本调用函数 源码 通用函数脚本program_log_new.sh function init_log(){sqlplus -S test/passw0rd@orcl EOFinsert into program_log values($id,$day,$1, s
实现记录SHELL执行的开始时间,结束时间,运行状态,错误信息等,以函数封装日志记录的方式,脚本调用函数
function init_log()
{
sqlplus -S test/passw0rd@orcl <
#!/bin/sh
. ~/.bash_profile
source program_log_new.sh //公用脚本
init_log sh_xx //初始化日志函数调用,传入程序名
shell命令xxx 2>${logdir}/xx_$time.log
exception_write //发生异常,调用异常,程序退出
shell命令xxx 2>${logdir}/xx_$time.log
exception_write //发生异常,调用异常,程序退出
....
shell命令xxx 2>${logdir}/xx_$time.log
finish_write //发生异常,调用异常,程序退出