shell脚本运行日志通用模块

原创
2016-06-07 15:59:55 1344浏览

目标 实现记录SHELL执行的开始时间,结束时间,运行状态,错误信息等,以函数封装日志记录的方式,脚本调用函数 源码 通用函数脚本program_log_new.sh function init_log(){sqlplus -S test/passw0rd@orcl EOFinsert into program_log values($id,$day,$1, s

目标

实现记录SHELL执行的开始时间,结束时间,运行状态,错误信息等,以函数封装日志记录的方式,脚本调用函数

源码

通用函数脚本program_log_new.sh
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                                       //发生异常,调用异常,程序退出

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。